Changing Values in a Datagrid Programmaticaly

Haklan

New member
Joined
Mar 22, 2005
Messages
2
Location
The Netherlands
Programming Experience
5-10
Hi everyone,

I'm using a Winform datagrid witch retrieves it's values from a dataset i filled.
In one column the values are numbers because the dataset is filled with numbers.
The thing I want to do is Change the values in the datagrid Coulumn programmaticaly.
For instance, the values in column 1 are lets say: 0-4
I dont want to show 0-4, but a text representing that value.
0 would show "ZERO"
1 Would show "ONE" etc.
Can this be done? and if so? how?

Thanx for the help.
 
Solved the problem myself.
Well, I have found a different approach to solve my problem.
Instead of trying to change the values in the datagridcoulumn programmatically after it as been bound to the datagridtablestyle . I should just change the values in the dataset before binding the datagrid to it.

My example:
VB.NET:
[size=1][color=#0000ff]Private[/color] [color=#0000ff]Sub[/color] SetStatusColoumDataGrid()[/size]
[size=1][color=#0000ff][color=#000000]	 [/color]Dim[/color] i [color=#0000ff]As[/color] [color=#0000ff]Integer[/color] = 0[/size]
[size=1][color=#0000ff]			If[/color] MyDataSet.Tables(0).Rows.Count <> 0 [color=#0000ff]Then[/color][/size]
[size=1][color=#0000ff]				 For[/color] i = 0 [color=#0000ff]To[/color] MyDataSet.Tables(0).Rows.Count - 1[/size]
[size=1][color=#0000ff][color=#000000]					 [/color]Select[/color] [color=#0000ff]Case[/color] (MyDataSet.Tables(0).Rows(i).Item([color=#800000]"status"[/color]))[/size]
[size=1]						[color=#0000ff]Case[/color] [color=#800000]"0"[/color][/size]
[size=1][color=#800000]							 [/color]MyDataSet.Tables(0).Rows(i).Item([color=#800000]"status"[/color]) = [color=#800000]"ZERO"[/color][/size]
[size=1][color=#800000]						[/color][color=#0000ff]Case[/color] [color=#800000]"1"[/color][/size]
[size=1][color=#800000]							 [/color]MyDataSet.Tables(0).Rows(i).Item([color=#800000]"status"[/color]) = [color=#800000]"ONE"[/color][/size]
[size=1][color=#800000]						[/color][color=#0000ff]Case[/color] [color=#800000]"2"[/color][/size]
[size=1][color=#800000]							 [/color]MyDataSet.Tables(0).Rows(i).Item([color=#800000]"status"[/color]) = [color=#800000]"TWO"[/color][/size]
[size=1][color=#800000]						[/color][color=#0000ff]Case[/color] [color=#800000]"3"[/color][/size]
[size=1][color=#800000]							 [/color]MyDataSet.Tables(0).Rows(i).Item([color=#800000]"status"[/color]) = [color=#800000]"THREE"[/color][/size]
[size=1][color=#0000ff][color=#800000]						[/color]Case[/color] [color=#0000ff]Else[/color][/size]
[size=1][color=#0000ff]							 [/color]MyDataSet.Tables(0).Rows(i).Item([color=#800000]"status"[/color]) = [color=#800000]"Nieuwe klacht"[/color][/size]
[size=1][color=#800000]					 [/color][color=#0000ff]End[/color] [color=#0000ff]Select[/color][/size]
[color=#0000ff][size=1]				 Next[/size][/color]
[size=1][color=#0000ff]			 End[/color] [color=#0000ff]If[/color][/size]
[size=1][color=#0000ff]End[/color] [size=2][color=#0000ff][size=1]Sub[color=#000000] [/color][/size][/color][/size][/size]

However I'm still interested in a method to change values programmatically in the Datagrid after the datagrid as been bound through a datagridtablestyle etc.. So if anyone as an example I would really appreciate.
 
Back
Top