2010-03-10 70 views
1

使复选框我有正在用一个柱填充作为一个布尔值来显示的值作为一个复选框GridControl图。帮助对C#的DevExpress XtraGrid中GridControl - 在细胞无形

不过,我想隐藏基于其他列的状态的一些复选框。我尝试使用gridView_CustomDrawCell()事件,但无法找到合适的属性。

我希望能够找到一个visible属性设置为false,但似乎并没有成为一个。

也许是可以隐藏的复选框的观点被填充时,但我不认为一个人的。

有谁知道这是可能的,如何?

非常感谢!

回答

4

你可以尝试清除Graphics并标记事件的处理:

private void gridView_CustomDrawCell(object sender, RowCellCustomDrawEventArgs e) 
{ 
    if (ConditionIsMet()) 
    { 
     e.Graphics.Clear(e.Appearance.BackColor); 
     e.Handled = true; 
    } 
} 

如果它不能正常工作,这里的另一个想法:处理CustomRowCellEditCustomRowCellEditForEditing事件,并删除编辑:

private void gridView_CustomRowCellEdit(object sender, CustomRowCellEditEventArgs e) 
{ 
    if (ConditionIsMet()) 
    { 
     e.RepositoryItem = null; 
    } 
} 
+0

+1使用CustomRowCellEditForEditing事件。 – 2010-03-10 17:30:05

+0

哇,我已经使用这个产品3年多了,从来没有意识到你可以将'RepositoryItem'设置为'null',我总是为禁用编辑器创建了一个默认项目。这会节省我一些时间! – Aaronaught 2010-03-11 04:12:28

+0

@Aaronaught,我不知道这是否真的有效,这只是一个建议;) – 2010-03-11 08:58:41

4

我做了这一个项目是什么设定一个RadioGroup中,与没有项目的控制,因此出现了空白。

private void viewTodoList_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e) 
     { 
      if (e.Column == CheckMarkColumn) 
      { 
       if (ConditionIsMet()) 
       { 
        e.RepositoryItem = new DevExpress.XtraEditors.Repository.RepositoryItemRadioGroup(); 
       } 
      } 
     }