private void AddCustomDataTableStyle()
{
DataGridTableStyle ts1 = new DataGridTableStyle();
ts1.MappingName = "Customers";
// Set other properties.
ts1.AlternatingBackColor = Color.LightGray; /* Add a GridColumnStyle and set its MappingName
to the name of a DataColumn in the DataTable.
Set the HeaderText and Width properties. */
DataGridColumnStyle boolCol = new DataGridBoolColumn();
boolCol.MappingName = "Current";
boolCol.HeaderText = "IsCurrent Customer";
boolCol.Width = 150;
ts1.GridColumnStyles.Add(boolCol);
// Add a second column style.
DataGridColumnStyle TextCol = new DataGridTextBoxColumn();
TextCol.MappingName = "custName";
TextCol.HeaderText = "Customer Name";
TextCol.Width = 250;
ts1.GridColumnStyles.Add(TextCol); /* Add the DataGridTableStyle instances to
the GridTableStylesCollection. */
myDataGrid.TableStyles.Add(ts1);
}
{
DataGridTableStyle ts1 = new DataGridTableStyle();
ts1.MappingName = "Customers";
// Set other properties.
ts1.AlternatingBackColor = Color.LightGray; /* Add a GridColumnStyle and set its MappingName
to the name of a DataColumn in the DataTable.
Set the HeaderText and Width properties. */
DataGridColumnStyle boolCol = new DataGridBoolColumn();
boolCol.MappingName = "Current";
boolCol.HeaderText = "IsCurrent Customer";
boolCol.Width = 150;
ts1.GridColumnStyles.Add(boolCol);
// Add a second column style.
DataGridColumnStyle TextCol = new DataGridTextBoxColumn();
TextCol.MappingName = "custName";
TextCol.HeaderText = "Customer Name";
TextCol.Width = 250;
ts1.GridColumnStyles.Add(TextCol); /* Add the DataGridTableStyle instances to
the GridTableStylesCollection. */
myDataGrid.TableStyles.Add(ts1);
}
解决方案 »
- 存储六位数字用什么类型好?
- c#????????
- 一个名称空间引用的小问题求教,在线等,100分送上
- C# 多图同时显示,如何让图片一副一副显示?
- DataTable 查询数据,修改保存
- winform应用程序+access部署问题,急!!!!!!!!!!!
- 怎样在c#中调用void EnableBusyDialog(BOOL bEnableBusy = TRUE );这个MFC函数?
- 静态方法中,如何得到当前类名?
- 我用VS2008 水晶报表开发,加载图片的时候是空白,后台查看是有数据
- get{} set{} 在什么时候用呢,作用是什么!(就15分了,谢谢!)
- 急!!!!如何在删除dataset中的记录时把数据库中对应的记录同时删除啊
- 報表問題
不过你可以在一个类中的方法里,直接操作此表,返回一个DataSet,然后直接把DataGrid的DataSource设置为返回的Dataset就行了