我有一个GridView,其中有一列,其中的RepositoryItemCheckEdit为ColumnEdit。我想只为一行禁用此控件。我怎样才能做到这一点?有什么建议么?在DevExpress中获取GridView的单元格控制
2
A
回答
2
您可以编辑只处理CustomRowCellEdit阅读:
private void gridView1_CustomRowCellEdit(object sender, CustomRowCellEditEventArgs e)
{
if(code goes here)
e.RepositoryItem.ReadOnly = true;
}
您还可以防止编辑从被显示的处理ShowingEditor:
private void gridView1_ShowingEditor(object sender, CancelEventArgs e)
{
if (code goes here)
e.Cancel = true;
}
0
在继承DataGridViewColum覆盖方法InitializeEditingControl 它的参数rowIndex处写这样的事情
this.DataGridView.EditingControl.Enbale = rowIndex != 3; // or the number you need
3
我已经找到了解决问题的方法的类。
gridView1.CustomRowCellEditForEditing += OnCustomRowCellEditForEditing;
private void OnCustomRowCellEditForEditing(object sender, CustomRowCellEditEventArgs e)
{
if (e.Column.FieldName != "MyFieldName") return;
*code here*
e.RepositoryItem.ReadOnly = true;
}
感谢您的答复。但是,是不是你的Windows.Forms DataGridView的解决方案?我正在使用Devexpress XtraGrid – 2010-01-07 13:46:13
我的错误是这是为Windows.Forms DataGridView – IordanTanev 2010-01-07 15:43:34