您的位置:首页 > 其它

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

2018-01-18 11:03 549 查看


首先在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);或者直接绑定该事件
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: