Programmatically adding buttons to a tableLayoutPanel
Hello everybody,
By adapting the code I've found here I am able to programmatically add buttons to my form as needed, but what I would like to be able to do is add my buttons to particular cells in a tableLayoutPanel.
I assume that a tableLayoutPanel has some form of row / column coordinate system for addressing each cell but I'm not having any luck in figuring it out.
Does anyone have any ideas how I might go about this. Thank you for your help.
Regards,
The Thing.
Re: Programmatically adding buttons to a tableLayoutPanel
I'm a newbie when it comes to Visual C# so it's taking me a while to get used to things, but I've managed to figure it out.
Code:
int cellX = 1; //.....or whatever value you need.
int cellY = 1; //.....or whatever value you need.
Button myButton = new Button();
tableLayoutPanel myTableLayoutPanel = new tableLayoutPanel();
myTableLayoutPanel.Controls.Add(myButton, cellX, cellY);
I'll investigate how to paint individual cells of a tableLayoutPanel and post the code when I have it done.
Thanks for checking out my thread anyway :)