datagridview應用過程中需要注意的屬性:
1.居中對齊標題列:
datagridview的默認屬性ColumnHeadersDefaultCellStyle裏設置Alignment:MiddleCenter,
2.datasource:
不能直接爲DATASET 必須爲DATASET.TABLES["index"],否則無法綁定數據信息
3.隱藏右側自動生成的列:
RowHeadersVisible:說明 "指示是否包含行標題的列"
4.單元格對齊方式的設置:
DataGridView的DefaultCellStyle屬性設置默認屬性
Columns的DefaultCellStyle屬性:如果在此處設置了屬性則其DataGridView的DefaultCellStyle屬性則
5.設置Datagridview爲縱向單行顯示數據
DataGridView的CellBorderStyle屬性
6.排序
如果不允許用戶對數據列進行排序,可以設置Columns的DefaultCellStyle屬性sort=notset。
7.多行顯示
Datagridview單元格默認不支持多行顯示,如果要設置爲多行,需要修改Datagridview的屬性DefaultCellStyle中WorpModel=true。