本文整理汇总了C#中System.Windows.Forms.DataGridViewColumn.Name属性的典型用法代码示例。如果您正苦于以下问题:C# DataGridViewColumn.Name属性的具体用法?C# DataGridViewColumn.Name怎么用?C# DataGridViewColumn.Name使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Windows.Forms.DataGridViewColumn
的用法示例。
在下文中一共展示了DataGridViewColumn.Name属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnumsAndComboBox_Load
private void EnumsAndComboBox_Load(object sender, System.EventArgs e)
{
// Populate the data source.
bindingSource1.Add(new Knight(Title.King, "Uther", true));
bindingSource1.Add(new Knight(Title.King, "Arthur", true));
bindingSource1.Add(new Knight(Title.Sir, "Mordred", false));
bindingSource1.Add(new Knight(Title.Sir, "Gawain", true));
bindingSource1.Add(new Knight(Title.Sir, "Galahad", true));
// Initialize the DataGridView.
dataGridView1.AutoGenerateColumns = false;
dataGridView1.AutoSize = true;
dataGridView1.DataSource = bindingSource1;
dataGridView1.Columns.Add(CreateComboBoxWithEnums());
// Initialize and add a text box column.
DataGridViewColumn column = new DataGridViewTextBoxColumn();
column.DataPropertyName = "Name";
column.Name = "Knight";
dataGridView1.Columns.Add(column);
// Initialize and add a check box column.
column = new DataGridViewCheckBoxColumn();
column.DataPropertyName = "GoodGuy";
column.Name = "Good";
dataGridView1.Columns.Add(column);
// Initialize the form.
this.Controls.Add(dataGridView1);
this.AutoSize = true;
this.Text = "DataGridView object binding demo";
}
DataGridViewComboBoxColumn CreateComboBoxWithEnums()
{
DataGridViewComboBoxColumn combo = new DataGridViewComboBoxColumn();
combo.DataSource = Enum.GetValues(typeof(Title));
combo.DataPropertyName = "Title";
combo.Name = "Title";
return combo;
}
#region "business object"
private class Knight
{
private string hisName;
private bool good;
private Title hisTitle;
public Knight(Title title, string name, bool good)
{
hisTitle = title;
hisName = name;
this.good = good;
}
public Knight()
{
hisTitle = Title.Sir;
hisName = "<enter name>";
good = true;
}
public string Name
{
get
{
return hisName;
}
set
{
hisName = value;
}
}
public bool GoodGuy
{
get
{
return good;
}
set
{
good = value;
}
}
public Title Title
{
get
{
return hisTitle;
}
set
{
hisTitle = value;
}
}
}
#endregion