2011-04-05 55 views
0

我有這個DevExpress GridContro我已經添加了兩個顏色一個包含repositoryItemCheckEdit和其他正常string類別的描述。在gridcontrol中的IsSetData從來沒有真正點擊checkEdit項目

現在,我已經在做地產板塊的repositoryItemCheckEdit一個未綁定的布爾並添加gridView1_CustomUnboundColumnData事件與e.IsGetData true,但在e.IsSetData觸發,當我點擊複選框是不正確的。任何人都可以解釋爲什麼這是? 感謝

private void gridView1_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e) 
{ 
    if (e.IsGetData) 
    { 
    string itemKey = ((CategoryTable)(gridControl1.ViewCollection[0]).GetRow(e.RowHandle)).Category; 
    if (AddressDoc == itemKey) e.Value = true 
    else e.Value = false; 
    } 

    if (e.IsSetData) 
    AddressDoc = ((CategoryTable)(gridControl1.ViewCollection[0]).GetRow(e.RowHandle)).Category; 
} 

回答

0

請嘗試從我們網站上公佈的How to save the value of an in-place check box as soon as it is changed知識庫文章的解決方案。它應該可以幫助你解決這個問題。另外,我已經檢查過你的代碼,它看起來並不安全。我會改變它如下:

private void gridView1_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e) { 
      GridView gridView = sender as GridView; 
      DataView dv = gridView.DataSource; 
      object c = DataView[e.ListSourceRowIndex]["Category"]; 
      string itemKey = c == null ? "" : c.ToString(); 
      if (e.IsGetData) { 
       if(AddressDoc == itemKey) 
        e.Value = true; 
       else 
        e.Value = false; 
      } 
      if(e.IsSetData) 
       AddressDoc = itemKey; 
     } 

我只能認爲你沒有適當調整未綁定的列。注意:列應該滿足兩個必須解除綁定的條件: 1)它的FieldName應該設置爲其他GridView列的fieldName屬性中的唯一值; 2)列的UnboundType應該設置爲非Bound值。

+0

我試過了'repositoryItemCheckEdit1_EditValueChanged'事件,你提供的鏈接解釋了我應該使用,但它永遠不會被解僱? – Domitius 2011-04-06 08:35:22

+0

編輯答案 – 2011-04-06 09:44:41

+0

不可以,名稱是唯一的,並且綁定類型是布爾值 – Domitius 2011-04-06 12:15:51

相關問題