private void CreateStyles(DataGrid dg)
{
DataGridTableStyle style = new DataGridTableStyle();
style
style
DataGridTextBoxColumn customerID = new DataGridTextBoxColumn();
customerID
customerID
customerID
DataGridTextBoxColumn name = new DataGridTextBoxColumn();
name
name
name
在定義了數據列後
style
(new DataGridColumnStyle[]{customerID
dg
}
private DataSet CreateDataSet()
{
string source =
string customers =
SqlConnection con = new SqlConnection(source);
SqlDataAdapter da = new SqlDataAdapter(customers
DataSet ds = new DataSet();
da
return ds;
}
static void Main()
{
Application
}
}
在創建了DataGridTableStyle對象後
屬 性
說 明
Alignment
HorizontalAlignment枚舉的一個值—— Left
表
這個CustomDataGridTableStyle示例的顯示結果如圖
圖
[
From:http://tw.wingwit.com/Article/program/net/201311/15055.html