DevExpress gridcontrol我们如何在gridview keydown事件中获取选定的行值 [英] DevExpress gridcontrol how we get selected row values in gridview keydown event
本文介绍了DevExpress gridcontrol我们如何在gridview keydown事件中获取选定的行值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨朋友们,
DevExpress gridcontrol如何在网格视图按键事件中获取所选行值。
在此先感谢....
Vineetha.K.Ravindranath
Hi Friends,
DevExpress gridcontrol how we get selected row values in grid view key down event.
Thanks in Advance....
Vineetha.K.Ravindranath
推荐答案
使用GridView的事件: RowClick 和 FocusedRowChanged 。
例如:
Use the events of the GridView: RowClick and FocusedRowChanged.
By example:
//RowClick Event for to detect the row to press click on GridView
private void myGrid_RowClick(object sender, DevExpress.XtraGrid.Views.Base.RowClickEventArgs e) {
//Validating selected row
if (e.RowHandle < 0) {
//Writing code for invalid row selected
} else {
//Recover information about row using some method: GetRow(), GetRowCellValue(), etc
register = (MyClass)myGrid.GetRow(e.RowHandle)).ShallowCopy();
oneValueOfCellOfRow = myGrid.GetRowCellValue(e.RowHandle, "OneNameOfFieldNameOfGrid");
}
}
//FocusedRowClick for detect when you move into grid with directons keys
private void myGrid_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) {
//Validating selected row
if (e.FocusedRowHandle < 0) {
//Writing code for invalid row selected
} else {
//Recover information about row using some method: GetRow(), GetRowCellValue(), etc
register = (MyClass)myGrid.GetRow(e.FocusedRowHandle));
oneValueOfCellOfRow = myGrid.GetRowCellValue(e.FocusedRowHandle, "OneNameOfFieldNameOfGrid");
}
}
注意:
当我将DataSource设置为Grid时,我向DataSource提供一个MyClass列表
Attention:
When i asign the DataSource to Grid, i assing to DataSource a List of MyClass
List<myclass> data = new List<myclass>();
//Some code to fill the data (using POCOS)
...
//Assing the data to DataSource
myGrid.DataSource = data;
</myclass></myclass>
您可以更好地将此问题发布到 Devexpress论坛 [ ^ ]。目标受众会更好。
You may have better luck posting this question to the Devexpress forums[^]. The target audience will be better there.
这篇关于DevExpress gridcontrol我们如何在gridview keydown事件中获取选定的行值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文