1

I am writing a windows forms application in visual studio 2010 (using VB). I want to change the control shown in a particular cell of a Table Layout Panel at runtime. Like this...

If radiobutton1.checked then tablelayoutpanel1's cell 1,1 shows panelOne 
else tablelayoutpanel1's cell 1,1 shows panelTwo 

Is this possible?

bernie2436
  • 22,841
  • 49
  • 151
  • 244
  • possible duplicate of [TableLayoutPanel's Control Columns properties](http://stackoverflow.com/questions/4948453/tablelayoutpanels-control-columns-properties) – Hans Passant Jan 04 '12 at 19:33

2 Answers2

1

A couple of ways to do this.

Put panels1 and 2 in side a new panel3, put that in the tablelayout panel, then do your logic from there. That way you don't have to where or possibly even if it is in the tablelayout panel.

Another way that might make sense would be to create your own user control, which encapsulates the beahviour of panel1 and 2 with a property on it that you set from the event handler...

Don't see how teh add remove idea is going to work, unless you can only have textbox once in the entire panel?

Tony Hopkinson
  • 20,172
  • 3
  • 31
  • 39
1

Take two textboxes and rather than removing the Textbox1 in Else useTableLayoutPanel1.Controls.Add(TextBox2, 1, 1) which I suppose is the panelTwo that you want to put.

Regards,

uday
  • 8,544
  • 4
  • 30
  • 54