D
D
dotrem2014-09-08 13:56:11
C++ / C#
dotrem, 2014-09-08 13:56:11

How to get cell value from GridView?

I have DevExpress's GridLookUpEdit control, respectively, there is a GridView in it. Now, when I hover over a grid line, I want to get data from this line (ideally, of course, get EditValue). According to the FocusedRowChange event, I do:

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());
            }
        }

And then I get an error saying that I don't have a column with index "1". But, what is strange in the designer, I added two columns.
What could be wrong here? And am I on the right track at all?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Silin, 2014-09-08
@dotrem

If you just get by index, then:

private void gridView_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            var view = sender as GridView;
            if (view != null)
            {
                MessageBox.Show(view[0,0].ToString());
            }
        }

Well, then you can go over ...
PS Perhaps there is a shorter record.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question