[英]How can I get The cell value of the gridControl when I click on a specific row?
I want to select the value of the firt cell when I click on a specific row in gridControl. 当我单击gridControl中的特定行时,我想选择第一单元格的值。
I tried this solution : 我尝试了以下解决方案:
int i=Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value.ToString())
But it seems it works only on gridView.Any Suggestins please? 但是似乎它只能在gridView上工作。
Take a look at the Obtaining and Setting Cell Values help-article - to obtain the specific row cell value you can use the ColumnView.GetRowCellValue method as follows: 查看“ 获取和设置单元格值”帮助文章-要获取特定的行单元格值,可以使用ColumnView.GetRowCellValue方法,如下所示:
ColumnView view = (ColumnView)gridControl1.MainView;
string idStr = view.GetRowCellValue(2, "ID").ToString()
If you are using the single-selection mode(the OptionsSelection.MultiSelect property is false ) you can use the following API to obtain cell values of a focused row: - ColumnView.GetFocusedRowCellValue ; 如果使用的是单选模式( OptionsSelection.MultiSelect属性为false ),则可以使用以下API获取焦点行的单元格值: -ColumnView.GetFocusedRowCellValue ; - ColumnView.GetFocusedRowCellDisplayText .
-ColumnView.GetFocusedRowCellDisplayText 。
These API utilized the handle of a currently focused row via the FocusedRowHandle property: 这些API通过FocusedRowHandle属性利用了当前焦点行的句柄 :
int id = (int)view.GetFocusedRowCellValue("Id");
To learn more, take a look at Accessing Rows in Code. 要了解更多信息,请看一下在代码中访问行。 Row Handles help article.
行句柄帮助文章。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.