Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
DataGridView
CHAPTER 8 – LESSON 3
There are six built-in types of columns you can use in a DataGridView
DataGridViewTextBoxColumn Use this column type to display text and
numeric values. A data-bound DataGridView automatically generates this type
of column when binding to strings and numeric values.
DataGridViewCheckBoxColumn Use this column to display Boolean values. A
DataGridView automatically generates this type of column when binding to
Boolean values.
DataGridViewImageColumn Use this column to display images. A DataGrid-
View automatically generates this type of column when binding to Image and
Icon objects. You can also bind a DataGridViewImage column to a byte array.
DataGridViewButtonColumn Use this column to provide users with a button
control.
DataGridViewComboBoxColumn Use this column type to present lists of
choices. This would typically be used for lookups to other tables.
DataGridViewLinkColumn Use this column type to display links to other data.
Configuring DataGridView Columns
For example, the following code sample creates a new text box column
named Product-Name:
// C#
DataGridViewTextBoxColumn ProductNameColumn = new
DataGridViewTextBoxColumn(); ProductNameColumn.Name
= "ProductName"; ProductNameColumn.HeaderText =
"Product Name";ProductNameColumn.ValueType =
System.Type.GetType("System.String");DataGridView1.Colu
mns.Add(ProductNameColumn); .
Deleting Columns in the DataGridView