GridView FocusedRowChanged - 子类对象

时间:2011-04-24 17:55:15

标签: c# events gridview devexpress

我需要一些帮助。

我从DevExpress EditorRow创建了一个名为MyEditorRow的子类,并添加了3个属性

public class myEditorRow : EditorRow
    {
        public myEditorRow()
        {
        }

        private string inRowDescription = null;
        public string RowDescription
        {
            get { return inRowDescription; }
            set { inRowDescription = value; }
        }

        private bool inRequired = false;
        public bool Required
        {
            get { return inRequired; }
            set { inRequired = value; }
        }

        private bool inInherits = false;
        public bool Inherits
        {
            get { return inInherits; }
            set { inInherits = value; }
        }

程序中某处的第二部分代码将MyEditorRow的实例添加到DevExpress VGrid Control。

vgcGrid.Rows.Add(Row);

我的问题是:如何将MyEditorRow类与DevExpress VGrid Control FocusedRowChanged事件相关联,这样我可以在行焦点更改时获取自定义属性。

由于

1 个答案:

答案 0 :(得分:0)

e.Row参数属于BaseRow类型。因此,要在FocusnedRowChanged事件处理程序中获取MyEditorRow对象的实例,请使用以下代码:

private void vGridControl1_FocusedRowChanged(object sender, DevExpress.XtraVerticalGrid.Events.FocusedRowChangedEventArgs e) {
    if(e.Row is myEditorRow) {
        myEditorRow row = ((myEditorRow)e.Row);
        // your code here
    }       
}