用devexpress把gridview的一列设置成combobox属性后,如何把其中一行改成dateedit属性

首先在In—place Edior Repository添加DateEdit属性

        /// <summary>
        /// 重写控件时间
        /// customRowcelledit事件,指定rowhandle设置其repositoryitem为repositoryitemdateedit
        /// </summary>
private void myGridView_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs  e)
        {

          //获取选择列的列名
            if (e.Column.FieldName == "值")
            {

              //e.RowHandle获取要选的行的序号

             //e.rowhandle=0,表示选择第一行
                string strFiledName = this.myGridView.GetRowCellValue(e.RowHandle, "字段").ToString();
                if (this.m_pFeatureCurrent != null && strFiledName!=null)
                {
                    int intFiledIndex = this.m_pFeatureCurrent.Fields.FindFieldByAliasName(strFiledName);
                    IField pField = this.m_pFeatureCurrent.Fields.get_Field(intFiledIndex);
                    if (pField.Type == esriFieldType.esriFieldTypeDate)
                    {

                      //重写控件
                        e.RepositoryItem = this.repositoryItemDateEdit1;
                    }
                }
            }
        }

然后就是需要实现gridView的单元格自定义编辑事件,如下所示。

       this.gridView1.CustomRowCellEdit += new DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventHandler(this.gridView1_CustomRowCellEdit);
或者直接绑定该事件


发布了6 篇原创文章 · 获赞 3 · 访问量 387

猜你喜欢

转载自blog.csdn.net/qq_33329834/article/details/79093366