2010-03-10 42 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(); 
       } 
      } 
     }