本文整理汇总了C#中Altaxo.Data.DataColumn.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# DataColumn.Clone方法的具体用法?C# DataColumn.Clone怎么用?C# DataColumn.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Altaxo.Data.DataColumn
的用法示例。
在下文中一共展示了DataColumn.Clone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyOrReplaceOrAdd
/// <summary>
/// Copies the data of the column (columns have same type, index is inside bounds), or replaces
/// the column (columns of different types, index inside bounds), or adds the column (index outside bounds).
/// </summary>
/// <param name="index">The column position where to replace or add.</param>
/// <param name="datac">The column from which the data should be copied or which should replace the existing column or which should be added.</param>
/// <param name="name">The name under which the column should be stored.</param>
public void CopyOrReplaceOrAdd(int index, DataColumn datac, string name)
{
if(index<ColumnCount)
{
if(this[index].GetType().Equals(datac.GetType()))
{
this[index].CopyDataFrom(datac);
}
else
{
// if the column to add has a parent, we can not add the column directly (we are then not the owner), so we clone it
Replace(index,datac.ParentObject==null ? datac : (DataColumn)datac.Clone());
}
}
else
{
// if the column to add has a parent, we can not add the column directly (we are then not the owner), so we clone it
Add(datac.ParentObject==null ? datac : (DataColumn)datac.Clone(), name);
}
}