Hi All,

I'm trying to create a table that has 2 columns and some number of rows. I would like to add an additional row at the end that is one cell which extends the entire row! I'll show you a simplified code. The problem is that the last row does not extend the entire table.

This is how it showing now:
┌────────┬────────┐
│..Column1...│..Column2..│
├────────┼────────┤
│..Column1...│..Column2..│
├────────┼────────┘
│..Merged.... │
└────────┘

This is how I would like it to be:
┌────────┬────────┐
│..Column1...│..Column2..│
├────────┼────────┤
│..Column1...│..Column2..│
├────────┴────────┤
│............Merged...............│
└─────────────────┘

Note: I tried to mess with width...etc. It didn't work for me.

private void Button1_Click(object sender, EventArgs e)
{
       for (int i=1; i<2; i++)
                  addRow("Column1","Column2");

	TableRow row = new TableRow();

	TableCell cell = new TableCell();

	cell.Text = "Merged";

	row.Cells.Add(cell);

	myTable.Rows.Add(row);       
}

private void addRow(string c1, string c2)
{
	TableRow row = new TableRow();

	TableCell cell = new TableCell();
	cell.Text = c1;			
	row.Cells.Add(cell);

	cell = new TableCell();
	cell.Text = c2;
	row.Cells.Add(cell);

	myTable.Rows.Add(row);
}

It depends what type of control you are using. I havent worked with them much, but i believe the older DataGird controls had a rowspan and columnspan attribute.

The newer DataGridView doesnt support this. There are third party controls that have this, or you can do it yourself. Generally this is acheived by handling the DataGridView's Paint event to redraw the cells to cover multiple columns/rows. Theres some code examples here at msdn.

It depends what type of control you are using. I havent worked with them much, but i believe the older DataGird controls had a rowspan and columnspan attribute.

The newer DataGridView doesnt support this. There are third party controls that have this, or you can do it yourself. Generally this is acheived by handling the DataGridView's Paint event to redraw the cells to cover multiple columns/rows. Theres some code examples here at msdn.

MyTable that I am using is an <asp:Table> control. Do I need to create my own control?

Ah, your using asp Tables...in that case check this out :)

Ryshed! I love you man!!!

Hi Use html code for creating the table.
use colspan="2" in the column which u want to be equal to the two above designed column.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.