Home > DeveloperSection > Forums > Arrange Button In c#
Manmohan Jha

Total Post:35

Posted on    November-18-2013 2:15 AM

 C# C# 

 1 Reply(s)
 1830  View(s)
Rate this:
How to auto arrange buttons like text in panel/container in c#

Thx & regards
Manmohan Jha

Sumit Kesarwani

Total Post:378

Posted on    November-18-2013 4:58 AM

Hi Manmohan,

You can do like this:

private void CreateButtonDynamic(int numberOfButton, string[] ButtonText)
   for (int i = 0; i < numberOfButton; i++)
      Button temp = new Button();
      temp.Name = "button"+(i+1).ToString();
      temp.Text = ButtonText[i];
      temp.AutoSize = true;
      temp.Location = new System.Drawing.Point(100, 100 + (25 * i));//please adjust location as per your need
      temp.Tag = i;
      temp.Click += new EventHandler(OnButtonClick); 

Don't want to miss updates? Please click the below button!

Follow MindStick