【问题标题】:GridView FocusedRowChanged - Child Class objectGridView FocusedRowChanged - 子类对象
【发布时间】:2011-04-24 17:55:15
【问题描述】:

我需要一些帮助。

我从 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 控件。

vgcGrid.Rows.Add(Row);

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

谢谢

【问题讨论】:

    标签: c# events gridview devexpress


    【解决方案1】:

    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
        }       
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-25
      相关资源
      最近更新 更多