【问题标题】:How to get value of cell at current row GridView winforms devexpress如何在当前行GridView winforms devexpress获取单元格的值
【发布时间】:2013-12-23 19:48:01
【问题描述】:

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

【问题讨论】:

  • 如果您使用 DataSource,您可以轻松地将 FocusedRow 转换为 DataSource 类型并获取值。否则,您需要处理答案中描述的 GetRowCellValue 方法。

标签: winforms gridview devexpress


【解决方案1】:

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

// 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");

【讨论】:

    【解决方案2】:
    【解决方案3】:
        public int idproductx;
    
        public void tProductGridView_RowClick(object sender, RowClickEventArgs e)        
        {        
          if (e.Clicks > 0)      
            {        
              idproductx = (int)((GridView)sender).GetRowCellValue(e.RowHandle, "idproduct ");                    
            }   
        }  
    

    【讨论】:

    • 你应该开发你的答案,而不是仅仅发布一个无法解释的解决方案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-02
    • 1970-01-01
    相关资源
    最近更新 更多