0

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);
}

Edited by all4peace: n/a

3
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by reach_shailshar
0

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.

0

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?

0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.