?? datagrid(綁定基礎(chǔ)).txt
字號:
DataGrid
綁定簡單,但樣式需要仔細(xì)考慮。
簡單綁定示例
al.Add(new Person("China",0));
al.Add(new Person("USA",1));
al.Add(new Person("Japan",2));
this.dataGrid1.DataSource=al;
public class Person
{
private string country=string.Empty;
public string Country
{
get{return country;}
set{country=value;}
}
private int code=0;
public int Code
{
get{return code;}
set{code=value;}
}
public Person(string country,int code)
{
this.country=country;
this.code=code;
}
}
樣式通過
DataGridTableStyle
MappingName(表名),GridColumnStyles
DataGridColumnStyle
MappingName(列名),NullText(單無顯示長度)
HeaderText(列標(biāo)題名稱),Width(列寬度)
1.設(shè)計器使用
a.單擊TableStyles.../只添加一次 定義表
b.單擊GridColumnStyles... 定義列
c.添加多次(多列)
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -