0

I am updating the Cellvalue of grid in Winforms on CellValueChanged event and it is working very fine for my hundreds of grids but getting null value for the specific column. Below is my code

private void gvResults_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
{
    string t = e.Value.ToString();
    string low = null;
    low = gridView.GetFocusedRowCellValue(gvResults.Columns["ColumnName"]).ToString();
}

I have checked the following measurements after googling 1. FieldName Uniqueness

Please suggest a solution and correct me if i am doing something wrong.

Thanks in advance

MethodMan
  • 18,625
  • 6
  • 34
  • 52
Arslan Elahi
  • 111
  • 1
  • 2
  • 12
  • 1
    have you looked at the DevExpress documentation https://documentation.devexpress.com/#WindowsForms/DevExpressXtraGridViewsBaseColumnView_GetFocusedRowCellValuetopic(vb2Cmw) your issue is the following `This issue occurs because the GetFocusedRowCellValue method is of the object type that cannot be implicitly converted to the type of the TextEdit.Text property that is String.` – MethodMan Jan 08 '16 at 20:02
  • its not about GetFocusedRowCellValue, its about CellValueChanged event returning null value. you see, e.value in the first line getting the null value on my specific column but rest of all it is doing great. – Arslan Elahi Jan 08 '16 at 20:10
  • i am converting the object to String explicitly. – Arslan Elahi Jan 08 '16 at 20:12
  • no that's Implicit not Explicit.. explicit would be `Convert.ToString()` it's casing is what your thinking...in the debugger what property's of `e` do you see when you set a breakpoint on the second line..? – MethodMan Jan 08 '16 at 20:14
  • RowHandle, Value, Column – Arslan Elahi Jan 08 '16 at 20:18
  • look at this link as well - https://documentation.devexpress.com/#WindowsForms/DevExpressXtraGridViewsBaseColumnView_CellValueChangedtopic – MethodMan Jan 08 '16 at 20:21
  • no hint on the link as well :( – Arslan Elahi Jan 08 '16 at 20:41

2 Answers2

1

Got the solution finally and it is If you bound the column with the grid then you need to add that column in the Datatable as well which you're assigning as DataSource to the Grid.

Arslan Elahi
  • 111
  • 1
  • 2
  • 12
0

what happens if you try this

private void gvResults_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
{
    string t = e.Value.ToString();
    string low = string.Empty;
    low = (string)gridView.GetFocusedRowCellValue( (string)gvResults.Columns["ColumnName"]);
}
MethodMan
  • 18,625
  • 6
  • 34
  • 52