当前位置: 首页>>代码示例>>C#>>正文


C# TableCell.SetValue方法代码示例

本文整理汇总了C#中TableCell.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# TableCell.SetValue方法的具体用法?C# TableCell.SetValue怎么用?C# TableCell.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TableCell的用法示例。


在下文中一共展示了TableCell.SetValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Clone

		private TableCell Clone(TableCell cell)
		{
			var newCell = new TableCell();
			if (DependencyPropertyHelper.GetValueSource(cell, TableCell.ColumnSpanProperty).BaseValueSource != BaseValueSource.Default)
				newCell.SetValue(TableCell.ColumnSpanProperty, cell.ColumnSpan);
			if (DependencyPropertyHelper.GetValueSource(cell, TableCell.RowSpanProperty).BaseValueSource != BaseValueSource.Default)
				newCell.SetValue(TableCell.RowSpanProperty, cell.RowSpan);
			if (DependencyPropertyHelper.GetValueSource(cell, TableCell.PaddingProperty).BaseValueSource != BaseValueSource.Default)
				newCell.SetValue(TableCell.PaddingProperty, cell.Padding);
			if (DependencyPropertyHelper.GetValueSource(cell, TableCell.BorderBrushProperty).BaseValueSource != BaseValueSource.Default)
				newCell.SetValue(TableCell.BorderBrushProperty, cell.BorderBrush);
			if (DependencyPropertyHelper.GetValueSource(cell, TableCell.BorderThicknessProperty).BaseValueSource != BaseValueSource.Default)
				newCell.SetValue(TableCell.BorderThicknessProperty, cell.BorderThickness);
			if (DependencyPropertyHelper.GetValueSource(cell, TableCell.TextAlignmentProperty).BaseValueSource != BaseValueSource.Default)
				newCell.SetValue(TableCell.TextAlignmentProperty, cell.TextAlignment);
			CopyProperties(cell, newCell);
			foreach (var block in cell.Blocks)
				newCell.Blocks.Add(Clone(block));
			return newCell;
		}
开发者ID:xbadcode,项目名称:Rubezh,代码行数:20,代码来源:TableProvider.cs

示例2: AddCellCopy

        // Creates a new cell copying all its properties from a currentRow. 
        // RowSpan property is not copied; it's set to default value of 1.
        // The new cell as added to a newRow (at the endPosition of its Cells collection).
        private static TableCell AddCellCopy(TableRow newRow, TableCell currentCell, int cellInsertionIndex, bool copyRowSpan, bool copyColumnSpan)
        { 
            Invariant.Assert(currentCell != null, "null check: currentCell");
 
            TableCell newCell = new TableCell(); 

            // Add the cell to a newRow's cell collection 
            // It's good to do it here before inserting inline formatting elements
            // to avoid unnecessary TextContainer creation and content copying.
            if (cellInsertionIndex < 0)
            { 
                newRow.Cells.Add(newCell);
            } 
            else 
            {
                newRow.Cells.Insert(cellInsertionIndex, newCell); 
            }

            // Copy all properties
            LocalValueEnumerator properties = currentCell.GetLocalValueEnumerator(); 
            while (properties.MoveNext())
            { 
                LocalValueEntry propertyEntry = properties.Current; 
                if (propertyEntry.Property == TableCell.RowSpanProperty && !copyRowSpan ||
                    propertyEntry.Property == TableCell.ColumnSpanProperty && !copyColumnSpan) 
                {
                    // Skipping table structuring properties when requested
                    continue;
                } 

                // Copy a property if it is not ReadOnly 
                if (!propertyEntry.Property.ReadOnly) 
                {
                    newCell.SetValue(propertyEntry.Property, propertyEntry.Value); 
                }
            }

            // Copy a paragraph for a cell 
            if (currentCell.Blocks.FirstBlock != null)
            { 
                Paragraph newParagraph = new Paragraph(); 

                // Transfer all known formatting properties that a locally set on a sourceBlock 
                Paragraph sourceParagraph = currentCell.Blocks.FirstBlock as Paragraph;

                if (sourceParagraph != null)
                { 
                    DependencyProperty[] inheritableProperties = TextSchema.GetInheritableProperties(typeof(Paragraph));
                    DependencyProperty[] nonInheritableProperties = TextSchema.GetNoninheritableProperties(typeof(Paragraph)); 
 
                    for (int i = 0; i < nonInheritableProperties.Length; i++)
                    { 
                        DependencyProperty property = nonInheritableProperties[i];
                        object value = sourceParagraph.ReadLocalValue(property);
                        if (value != DependencyProperty.UnsetValue)
                        { 
                            newParagraph.SetValue(property, value);
                        } 
                    } 
                    for (int i = 0; i < inheritableProperties.Length; i++)
                    { 
                        DependencyProperty property = inheritableProperties[i];
                        object value = sourceParagraph.ReadLocalValue(property);
                        if (value != DependencyProperty.UnsetValue)
                        { 
                            newParagraph.SetValue(property, value);
                        } 
                    } 
                }
 
                // Add paragraph to a cell
                newCell.Blocks.Add(newParagraph);
            }
 
            return newCell;
        } 
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:79,代码来源:TextRangeEditTables.cs


注:本文中的TableCell.SetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。