Modify value at the time of binding DataGrid Compact Framwork -


I used the binding source to bind DataGrid in my window 6.5 application. But the problem is that I want to change the text of a column from Int to string while the grid is binding.

If you are looking at the code below, then I am bound with the datagrid designation which is 502 value but I need to display "SE" instead, I can not assume that in my candidate object so that I need to modify the DataGrid on runtime. I do not know how I can get it. Please help . Thanks

  cand.Add (new candidate {ID = 10, name = "Andrew", designation = 501, DCOD = "SSE"}); Cand.Add (new candidate {ID = 11, name = "Peter", designation = 502, DCode = "SE"}); DatagridTableStyleMyDataGridTableStyle = NewDataGridTableStyle (); MyDataGridTableStyle.MappingName = "candidate"; DataGridTextBoxColumn colA = New DataGridTextBoxColumn (); ColA.MappingName = "name"; ColA.HeaderText = "Field A"; ColA.Width = 50; DataGridTextBoxColumn colB = New DataGridTextBox column (); Colb.MappingName = "Designation"; Colb.HeaderText = "Holding Position"; ColB.Width = 100; //dataGrid1.CurrentCell.ColumnNumber. DataGridTextBoxColumn colC = New DataGridTextBoxColumn (); ColC.MappingName = "DCode"; ColC.HeaderText = "Code Status"; Colc.Width = 50; MyDataGridTableStyle.GridColumnStyles.Add (cola); MyDataGridTableStyle.GridColumnStyles.Add (colB); MyDataGridTableStyle.GridColumnStyles.Add (colC); MyBindingSource.DataSource = cand.ToBindingList (); MyDataGridTableStyle.MappingName = myBindingSource.GetListName (empty); DataGrid1.TableStyles.Clear (); // Recommended on MSDN in code examples. DataGrid1.TableStyles.Add (myDataGridTableStyle); DataGrid1.DataSource = myBindingSource;  

Why do not you make DCode assets a slave for your designation property: < / P>

  cabinet c = new candidate (); C. Design = 501; Print (sidod); // Output "SSE"  

Then when you just want a string interpretation of the designation, you can tie it in DCOD.


Comments