Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1700
Add multiple cells in TableCellNode
posted

Hello,

I want to add cells into one cell.

My code is :

tcn = trn.ChildNodes[3] as TableCellNode;
if (rowCounter % 2 != 0) tcn.Settings = rowAlternatingSettings;
else tcn.Settings = rowSettings;
pn = tcn.ChildNodes[0] as ParagraphNode;
pn.ChildNodes.Add(CreateRunNodeWithContent(charSettings, "1"));
pn.ChildNodes.Add(CreateRunNodeWithContent(charSettings, "2"));
pn.ChildNodes.Add(CreateRunNodeWithContent(charSettings, "3"));

To have 1,2,3 in 3 cells hosted by one.

I try this but I'm out of index :

tcn = trn.ChildNodes[3] as TableCellNode;
if (rowCounter % 2 != 0) tcn.Settings = rowAlternatingSettings;
else tcn.Settings = rowSettings;
pn = tcn.ChildNodes[0] as ParagraphNode;
pn.ChildNodes.Add(CreateRunNodeWithContent(charSettings, "1"));

pn = tcn.ChildNodes[1] as ParagraphNode;
pn.ChildNodes.Add(CreateRunNodeWithContent(charSettings, "2"));

pn = tcn.ChildNodes[2] as ParagraphNode;
pn.ChildNodes.Add(CreateRunNodeWithContent(charSettings, "3"));

3 cells is an example, I can have 10 or 20 cells to host.

Could you help me ?

Parents
  • 34810
    Offline posted

    Hello Thomas,

    I am a little bit unsure what you are asking here. I see that you are adding three child nodes to your paragraph node, which appears to be placed in a table cell node (tcn). You say that you want to have your "1 2 3" content "in 3 cells hosted by one." I am under the impression that this means you would like to see three cells within a single cell of your table. Please correct me if I am incorrect, as my following explanation goes off of this impression.

    Currently, you cannot place TableCellNodes within other TableCellNodes, but you can host tables within ParagraphNodes. Since you can do that, I would recommend using the below code to add a new table into your paragraph node at tcn.ChildNodes[index]:

    ParagraphNode pn = tcn.ChildNodes[0] as ParagraphNode;
    pn.Document.InsertTable(0, 3, 1, out error);

    The above obtains the first child node of a TableCellNode, and adds a 3 column, 1 row table into the paragraph node inside of the parent cell. I hope this helps you. Although, there is the possibility that my impression on this is flawed, and so if my above impression was incorrect, could you please provide some additional information on the functionality that you are looking to achieve?

    Sincerely,
    Andrew
    Associate Developer
    Infragistics Inc.
    www.infragistics.com/support

Reply Children