我怎樣才能改變一個DataGrid列的標題在後面的代碼?如何更改DataGrid列的標題在後面的代碼?
例子:
var dataGrid = new DataGrid();
dataGrid.ItemsSource = someRecords;
// ... now I want to change a column header ...
我怎樣才能改變一個DataGrid列的標題在後面的代碼?如何更改DataGrid列的標題在後面的代碼?
例子:
var dataGrid = new DataGrid();
dataGrid.ItemsSource = someRecords;
// ... now I want to change a column header ...
使用DataGrid.Columns:
dataGrid.Columns[0].Header = "New Header for column 0";
您可以更改數據網格的頭在Page_Load
dataGrid.HeaderRow.Cells[0].Text = "Any thing that you want to Enter";
我會用你綁定的物品類別的DisplayName
如下面
public class YourItemClass
{
[DisplayName("Column Name")]
public string SomeProperty{ get; set; }
}
這個問題是關於WPF ['DataGrid'](http://msdn.microsoft.com/en-us/library/system.windows.controls.datagrid(v = vs.110).aspx) –