2012-06-12 49 views
0

我使用AutoPopulateColumns系統在DataGrid上顯示我的結構。是否有任何屬性的屬性在ColumnChooser窗口上顯示屬性,而不是在網格上?DevExpress DataGrid的ColumnChooser

謝謝。

+0

你想顯示哪個屬性..問題不是很清楚..請詳細說明.. –

+0

我需要顯示我的類的屬性不在網格上,但在ColumnChooser窗體上,我使用AutoPopulateColumns,所以有沒有任何屬性如「DisplayName」或「Browsable」爲此? –

回答

0

好吧,我找不到這樣的默認屬性,所以我創建了自己的空屬性,稱之爲「ShowInColumnChooserAttribute」。

馬克所有屬性,我並不需要在DataGrid後,但需要在ColumnChooser與此屬性

而且在DataGrid的事件「ColumnsPopulated」做了下:

 var hiddenList = new List<string>(); 
     var r = dataTable.ItemsSource.GetType().GetGenericArguments()[0]; 
     foreach (var prop in r.GetProperties()) 
      if (prop.GetCustomAttributes(typeof(ShowInColumnChooserAttribute), true).Length > 0) 
       hiddenList.Add(prop.Name); 
     foreach (var column in ((DevExpress.Xpf.Grid.GridControl)sender).Columns) 
       column.Visible = !hiddenList.Contains(column.FieldName); 

我認爲這是非常容易和美麗的解決方案!希望這會有所幫助!

相關問題