views:

425

answers:

1

I have a tablelayoutpanel. 2x2 - 2 columns 2 rows.

For example, I added a button button1 in a 1 row, second column. button1 has a dock property set to Fill. VS Designer allows to set column/row span properties of button1.

I want an availability to change row span property of button1 programatically, so it can fill all second column(1 row and second row) and availability to set it back.

How ?

+1  A: 

What about this code?

private void button1_Click(object sender, EventArgs e)
{
    var control = sender as Control;

    if(control == null)
        return;

    if (1 == tableLayoutPanel1.GetRowSpan(control))
    {
        tableLayoutPanel1.SetRowSpan(control, 2);
    }
    else
    {
        tableLayoutPanel1.SetRowSpan(control, 1);
    }
}
Oliver
great code.Visual Studio Designer mislead me. I was looking in button1 properties, was trying to cast button1 to toolstippanel item and so on... thanks !
alex
if you had looked into Form.Designer.cs instead of visual designer you had the solution found directly. ;-)
Oliver