2011-04-24 65 views
0

我需要一些幫助。GridView FocusedRowChanged - 子類對象

我已經創建了一個名爲從DevExpress的EditorRow MyEditorRow一個子類,並添加3個屬性

public class myEditorRow : EditorRow 
    { 
     public myEditorRow() 
     { 
     } 

     private string inRowDescription = null; 
     public string RowDescription 
     { 
      get { return inRowDescription; } 
      set { inRowDescription = value; } 
     } 

     private bool inRequired = false; 
     public bool Required 
     { 
      get { return inRequired; } 
      set { inRequired = value; } 
     } 

     private bool inInherits = false; 
     public bool Inherits 
     { 
      get { return inInherits; } 
      set { inInherits = value; } 
     } 

代碼的第二部分中的某處程序添加MyEditorRow的實例的DevExpress VGrid控制。

vgcGrid.Rows.Add(Row); 

我的問題是:如何鏈接MyEditorRow類的DevExpress VGrid控制FocusedRowChanged事件,所以我可以讓我的自定義屬性的行更改焦點時。

謝謝

回答

0

e.Row參數屬於BaseRow類型。因此,要獲取FocusnedRowChanged事件處理程序中MyEditorRow對象的實例,請使用以下代碼:

private void vGridControl1_FocusedRowChanged(object sender, DevExpress.XtraVerticalGrid.Events.FocusedRowChangedEventArgs e) { 
    if(e.Row is myEditorRow) { 
     myEditorRow row = ((myEditorRow)e.Row); 
     // your code here 
    }  
} 
+0

謝謝,工作起來像一個魅力 – StewieGriffin 2011-04-24 21:12:04