本文整理汇总了C#中NsNode.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# NsNode.CopyTo方法的具体用法?C# NsNode.CopyTo怎么用?C# NsNode.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NsNode
的用法示例。
在下文中一共展示了NsNode.CopyTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetColumns
/// <summary>
/// Sets the column types and headers using the passed node as a template. 1 column per attribute
/// </summary>
/// <param name="n">the node used to set the columns</param>
public int SetColumns(NsNode n)
{
if (n != null)
{
//store a template node for creating new
m_template = new NsNode("temparent");
m_template = n.CopyTo(m_template);
m_template.Label = "template";
m_template.Parent = null;//delete temparent
}
if (m_template == null)
return -1;
Grid.Columns.Clear();
//label
Grid.Columns.Add("Label", "Label");
//attributes
DataGridViewColumn col = null;
foreach (IAttribute a in m_template.Attributes)
{
if (a is DoubleAttribute)
{
col = new DataGridViewTextBoxColumn();
col.ValueType = typeof(double);
col.DefaultCellStyle.Format = "#0.000";
col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
}
else if (a is BoolAttribute)
{
col = new DataGridViewCheckBoxColumn();
col.ValueType = typeof(bool);
}
else if (a is IntAttribute)
{
col = new DataGridViewTextBoxColumn();
col.ValueType = typeof(int);
col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
}
else if (a is DateAttribute)
{
col = new DataGridViewTextBoxColumn();
col.ValueType = typeof(DateTime);
}
else
col = new DataGridViewTextBoxColumn();
col.HeaderText = a.Label;
col.Name = a.Label;
col.AutoSizeMode = ColumnMode;
//Grid.Columns.Add(a.Label, a.Label);
Grid.Columns.Add(col);
}
if (ReadOnlys != null)
{
foreach (int i in ReadOnlys)
{
if ( i < 0 || Grid.Columns.Count <= i)
continue;
Grid.Columns[i].ReadOnly = true;
Grid.Columns[i].DefaultCellStyle.BackColor = Color.LightGray;
}
}
return Grid.Columns.Count;
}