程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> 關於C語言 >> C#中對DatagridView的部分常用操作(2)

C#中對DatagridView的部分常用操作(2)

編輯:關於C語言

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. 下一頁:
Copyright © 程式師世界 All Rights Reserved