Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to merge two cells in Table Layout

I have two rows and two columns. I want last column of both cells merge into one. Due to requirement I do not use other design options means two tablelayouts in which first table layout has two rows.I am use Winforms in C#.

|                       |                    | |                       |                    | |                       |                    | |_______________________|                    | |                       |                    | |                       |                    | |                       |                    | 
like image 745
Abhijit Shelar Avatar asked Feb 22 '12 07:02

Abhijit Shelar


People also ask

Can you merge two cells of a table made in Word How?

Merge cells Select the cells that you want to merge. Select Layout > Merge Cells. To unmerge cells, select the cells and select Unmerge Cells. Note: In Excel, select the cells you want and select Merge & Center.

Why can't I merge cells in a table?

The most common reason for cells not to merge is that they are in an Excel Table. Excel Table doesn't allow its cells to be merged. As a result, we have to convert the Table to a normal range to be able to apply cell merge.


2 Answers

  1. Put any control into a cell in form designer
  2. Select the control and view its properties
  3. Find "ColumnSpan" property in "Layout" section
  4. Input desired column span for this value

See picture for illustration:

enter image description here

like image 195
Boris Zinchenko Avatar answered Sep 26 '22 03:09

Boris Zinchenko


Here's how to do it in code

//create a label control, add it to the tableLayoutPanel, and merge it into 3 cells. Label lbl = new Label(); lbl.Location = new Point(0, 0); lbl.Text = "This is a test label"; MyTableLayoutPanel.Controls.Add(lbl, 0,0);  //start it in cell 0,0 MyTableLayoutPanel.SetColumnSpan(lbl, 3);  //merge 3 columns 
like image 32
NL3294 Avatar answered Sep 23 '22 03:09

NL3294