6
的列標題列索引如何從獲得Column
指數或Column.DisplayIndex
其Column Header
在WPF
DataGrid
?我知道Column Header
,想要得到column index
。獲取在WPF的DataGrid
的列標題列索引如何從獲得Column
指數或Column.DisplayIndex
其Column Header
在WPF
DataGrid
?我知道Column Header
,想要得到column index
。獲取在WPF的DataGrid
你可以使用DisplayIndex
(注意,如果列是使出這將改變)
var index = dataGrid.Columns.Single(c => c.Header.ToString() == "HeaderName").DisplayIndex;
編輯:感謝您的建議,從@AnHX
看起來像「保」有一個小錯誤。這裏是我的代碼:
var index = dataGrid.Columns.Single(c => c.Header.ToString() == "HeaderName").DisplayIndex;
Thanks @paul ..它爲我工作。 – Kishor
查看AnHx發佈的修補程序。此代碼比較參考沒有值。 – buckley