Reputation: 5299
I have a GridLookUpEdit and wath to get a edit value on FocusedRowChanged event:
private void gridView_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
{
var view = sender as GridView;
if (view != null)
{
MessageBox.Show(view.GetRowCellValue(e.FocusedRowHandle, view.Columns[1]).ToString());
}
}
But here i get a error says that i out of column array. But i have a two columns, first column visible, second not visible.
Whats wrong here? And how can i get EditValue more correctly if possible?
Upvotes: 0
Views: 1995
Reputation: 6621
It seems that your view has only one column and there are two columns in your underlying datasource. So, you can get a value from underlying datasource.
If your underlying datasource is DataTable
then you can use ColumnView.GetDataRow
method:
MessageBox.Show(view.GetDataRow(e.FocusedRowHandle)[1].ToString());
If your underlying datasource is List<SomeObject>
then you can use ColumnView.GetDataSourceRowIndex
method:
MessageBox.Show(YourList[view.GetDataSourceRowIndex()].YourColumn.ToString());
Or you can add second column by using ColumnView.Columns
collection:
var column = view.Columns.AddField("YourField");
column.Visible = false;
Upvotes: 1