本文整理汇总了C#中System.Windows.Forms.DataGridViewColumn.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# DataGridViewColumn.Clone方法的具体用法?C# DataGridViewColumn.Clone怎么用?C# DataGridViewColumn.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.DataGridViewColumn
的用法示例。
在下文中一共展示了DataGridViewColumn.Clone方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Form1
public Form1() {
//this.AutoSize = true;
DataGridView dgv = new DataGridView();
//dgv.Size = new Size(500,250);
dgv.Location = new Point(10,10);
dgv.RowTemplate = new DataGridViewRow();
DataGridViewColumn col = new DataGridViewColumn();
col.CellTemplate = new DataGridViewTextBoxCell();
dgv.Columns.Add(col.Clone() as DataGridViewColumn);
dgv.Columns.Add(col.Clone() as DataGridViewColumn);
dgv.Columns.Add(col.Clone() as DataGridViewColumn);
dgv.RowCount = 4;
dgv.EnableHeadersVisualStyles = false;
dgv.AutoSize = true;
this.Controls.Add(dgv);
this.Text = "DataGridView advanced border styles demo";
}
示例2: Form1
public Form1() {
//this.AutoSize = true;
dgv = new DataGridView();
Console.WriteLine("AdvancedCellBorderStyle: " + dgv.AdvancedCellBorderStyle.ToString());
//dgv.Size = new Size(500,250);
dgv.Location = new Point(10,10);
dgv.RowTemplate = new DataGridViewRow();
DataGridViewColumn col = new DataGridViewColumn();
col.CellTemplate = new DataGridViewTextBoxCell();
dgv.Columns.Add(col);
DataGridViewColumn col2 = col.Clone() as DataGridViewColumn;
col2.CellTemplate = col.CellTemplate;
dgv.Columns.Add(col2);
DataGridViewColumn col3 = col.Clone() as DataGridViewColumn;
col3.CellTemplate = col.CellTemplate;
dgv.Columns.Add(col3);
dgv.RowCount = 4;
dgv.EnableHeadersVisualStyles = false;
dgv.AutoSize = true;
dgv.CellPainting += OnCellPainting;
this.Controls.Add(dgv);
this.Text = "DataGridView advanced border styles demo";
}
示例3: SetTotalColumns
//合计列的位置对应
private void SetTotalColumns(DataGridViewColumn col)
{
bool b_Col = false;
DataGridViewColumn newcol = new DataGridViewColumn();
newcol = (DataGridViewColumn)col.Clone();
newcol.DisplayIndex = col.DisplayIndex;
newcol.Visible = col.Visible;
foreach (DataGridViewColumn d_co in botTotal.Columns)
{
if (d_co.Name == newcol.Name)
{
b_Col = true;
break;
}
}
if (b_Col)
{
botTotal.Columns.Remove(newcol.Name);
}
//newcol.HeaderText = newcol.Name;
if (newcol.Name != "")
{
System.Windows.Forms.DataGridViewTextBoxColumn ColNew = new DataGridViewTextBoxColumn();
ColNew.Name = newcol.Name;
ColNew.DisplayIndex = newcol.DisplayIndex;
ColNew.Visible = newcol.Visible;
ColNew.DataPropertyName = newcol.DataPropertyName;
botTotal.Columns.Add(ColNew);
//botTotal.Columns.Add(newcol);
}
}