本文介绍了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

推荐答案

//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 gridcontrol我们如何在gridview keydown事件中获取选定的行值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 23:06