ARRANGE BUTTON IN C#

Manmohan Jha

Total Post:35

Points:245
Posted by  Manmohan Jha
C# 
C#
 1907  View(s)
Ratings:
Rate this:
How to auto arrange buttons like text in panel/container in c#

Thx & regards
Manmohan Jha
  1. Sumit Kesarwani

    Post:378

    Points:2694
    Re: Arrange Button In c#

    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); 
          this.Controls.Add(temp);
        }
    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!