简体   繁体   English

C# - DevExpress - GridControl - DataGridView

[英]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.我使用 DevExpress 控件——我有一个 GridControl 和一个内置的 GridView——我从数据库下载数据——sqlDataSource。

I want to select a row in a grid and then display a column value of 1 from the selected record.我想 select 网格中的一行,然后从所选记录中显示列值为 1。

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.不工作。

I solved the problem.我解决了这个问题。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM