.NET

Reply
Active Contributor
chikito1990
Posts: 40
Registered: ‎06-26-2013
Message 1 of 2 (735 Views)
Accepted Solution

Merging two cells in a row?

735 Views, 1 Replies
08-12-2013 03:15 AM

Hi all,

 

I am trying to merge two cells in one but i cannot find proper method to do that. Any suggestions?

 

Example:
I am creating a table with dynamic number of rows and columns: 

 for (int i = 3; i < tbRight.NumRows; i++)
                {
                    for (int j = 0; j < tbRight.NumColumns; j++)
                    {
                        if (num2 == numCircles - 1)
                        {
                            Cell c = new Cell(tbRight, i, j);
                            c.TextHeight = 450;
                            tbRight.SetTextString(i, j, (num2 + 1).ToString() + "# - " + rightConn[num2]);
                            num2++;
                            
                        }
                        else if (num2 > numCircles - 1)
                        {   }
                        else
                        {
                            Cell c = new Cell(tbRight, i, j);
                            c.TextHeight = 450;
                            tbRight.SetTextString(i, j, (num2 + 1).ToString() + "# - " + rightConn[num2]);
                            num2++;
                        }
                    }
                }

 First row of the table is the header and i have two free rows with two columns each. I want to merge all of them to look like one row.

 

 

On the other hand, is it possible to align the text in the table in the middle and also the vertical align to be in the middle.

 

Thank you in advance!

Hi,

 

You can merge cell ranges, like this:

 

Private Sub FormatCells(ByVal ft As Table, ByVal row As Integer, ByVal start As Integer, ByVal fend As Integer)
Dim rc As CellRange = CellRange.Create(ft, row, start, row, fend)
ft.MergeCells(rc)
End Sub

 

Gaston Nunez

Distinguished Mentor
gasty1001
Posts: 582
Registered: ‎04-11-2010
Message 2 of 2 (698 Views)

Re: Merging two cells in a row?

08-12-2013 08:56 AM in reply to: chikito1990

Hi,

 

You can merge cell ranges, like this:

 

Private Sub FormatCells(ByVal ft As Table, ByVal row As Integer, ByVal start As Integer, ByVal fend As Integer)
        Dim rc As CellRange = CellRange.Create(ft, row, start, row, fend)
        ft.MergeCells(rc)
    End Sub

 

Gaston Nunez

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.