WEB开发网
开发学院软件开发C语言 C#中对DatagridView的部分常用操作 阅读

C#中对DatagridView的部分常用操作

 2009-05-21 08:27:46 来源:WEB开发网   
核心提示: 3、可以绑定并显示对象Bind Objects to Windows Forms DataGridView Controls4、可以改变表格线条风格Change the Border and Gridline Styles in the Windows Forms DataGridView

3、可以绑定并显示对象

Bind Objects to Windows Forms DataGridView Controls

4、可以改变表格线条风格

Change the Border and Gridline Styles in the Windows Forms DataGridView Control

Samples:

this.dataGridView1.GridColor = Color.BlueViolet;
this.dataGridView1.BorderStyle = BorderStyle.Fixed3D;
this.dataGridView1.CellBorderStyle = DataGridViewCellBorderStyle.None;
this.dataGridView1.RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single;
this.dataGridView1.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single;

5、动态改变列是否显示,和动态改变列的显示顺序

Change the Order of the Columns in the Windows Forms DataGridView Control

Samples:

customersDataGridView.Columns["CustomerID"].Visible = false;
customersDataGridView.Columns["ContactName"].DisplayIndex = 0;
customersDataGridView.Columns["ContactTitle"].DisplayIndex = 1;
customersDataGridView.Columns["City"].DisplayIndex = 2;
customersDataGridView.Columns["Country"].DisplayIndex = 3;
customersDataGridView.Columns["CompanyName"].DisplayIndex = 4;

6、可以在列中显示图像

Display Images in Cells of the Windows Forms DataGridView Control

Samples:

Icon treeIcon = new Icon(this.GetType(), "tree.ico");
DataGridViewImageColumn iconColumn = new DataGridViewImageColumn ();
iconColumn.Image = treeIcon.ToBitmap();
iconColumn.Name = "Tree";
iconColumn.HeaderText = "Nice tree";
dataGridView1.Columns.Insert(2, iconColumn);

上一页  1 2 3 4  下一页

Tags:DatagridView 部分 常用

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接