TomProjectID_23
TomProjectID_23

Reputation: 43

C# - DevExpress - GridControl - DataGridView

I use DevExpress controls - I have a GridControl and a built-in GridView - I download the data from the database - sqlDataSource.

I want to select a row in a grid and then display a column value of 1 from the selected record.

How to do it?

The following code returns an empty field.

int savedRowIndex;
        savedRowIndex = gridView1.FocusedRowHandle;

        var test1 = gridView1.GetRowCellValue(savedRowIndex, "columnName");

        MessageBox.Show(test1.ToString());

or ...

private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
    {
        textBox1.Text = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "colName").ToString();
    }

Doesn't work.

Upvotes: 0

Views: 573

Answers (1)

TomProjectID_23
TomProjectID_23

Reputation: 43

I solved the problem.

var strRow = grid.GetRowCellValue(grid.FocusedRowHandle, grid.Columns[0]).ToString();

Upvotes: 1

Related Questions