如何在当前行获取单元格的值GridView winforms devexpress

时间:2013-12-23 19:48:01

标签: winforms gridview devexpress

在点击“编辑”按钮之前,我需要知道我选择哪一行并获取单元格值(例如:idproduct)。

3 个答案:

答案 0 :(得分:3)

正如@brendon所指,如果gridView是View上的当前GridControl

// Get your currently selected grid row
var rowHandle = gridView.FocusedRowHandle;

// Get the value for the given column - convert to the type you're expecting
var obj = gridView.GetRowCellValue(rowHandle, "FieldName");

答案 1 :(得分:0)

答案 2 :(得分:0)

    public int idproductx;

    public void tProductGridView_RowClick(object sender, RowClickEventArgs e)        
    {        
      if (e.Clicks > 0)      
        {        
          idproductx = (int)((GridView)sender).GetRowCellValue(e.RowHandle, "idproduct ");                    
        }   
    }