Hi,
hey i need a code to display the text of of runtime generated button in ascending order in windows application c#.

example if i have buttons like
ab
abc
asdfsd
asasasasas
how to get the text in regular order starting from left?

thank,
suhasini

Do you mean that the text in your buttons has to be left aligned?

hey hi,
yes the text on the run time generated buttons should be left aligned or the buttons have 3 charactes shud be displayed at the top and as the lengh goes on incresing they shud be displayed next.

Thank,
suhasini.

The TextAlign property is default set to MiddleCenter, set it to MiddleLeft.
I should make a List of all the text to put into the buttons. Sort the List and then assign every item in the List to the Text property of the buttons.

The TextAlign property is default set to MiddleCenter, set it to MiddleLeft.
I should make a List of all the text to put into the buttons. Sort the List and then assign every item in the List to the Text property of the buttons.

but my buttons are binded with database and are generated at runtime
so im not getting any properties such as middleleft.

but my buttons are binded with database and are generated at runtime
so im not getting any properties such as middleleft.

my method is

private void LoadRegVisit()
        {
            int i = 0;
            int j = 0;
            BuzySoft.Domain.RegVisit reg = new BuzySoft.Domain.RegVisit();
            reg.Formid = 27;
            BuzySoft.Domain.RegVisits regVisits = BusinessServices.RegVisitServices.GetRegVisitID(reg);
            DataSet ds = regVisits.DsRegVisits;
            int count = 1;
            foreach (Domain.RegVisit rgn in regVisits)
            {
                btnRun = new SimpleButton();
                btnRun.Tag = rgn.DestinationFormId;
                btnRun.Text = rgn.MenuDescription;
                TextBox.

                // btnRun.AutoSize = true;
                btnRun.Location = new System.Drawing.Point(15, 65 + 30 * i);
                btnRun.Name = rgn.MenuDescription;
               
                btnRun.BackColor = System.Drawing.Color.Black;
                btnRun.Size = new System.Drawing.Size(190, 30);

                this.Controls.Add(btnRun);
                if (count == 2)
                {
                    btnRun.Location = new System.Drawing.Point(200, 65 + 60 * j);
                    j++;
                    count = 0;
                }
                count++;
                // groupBox1.Controls.Add(newlabel);
                //.Size = new System.Drawing.Size(100, 25);
                //this.Controls.Add(btnRun);ds.Tables[0].Rows.Count
                btnRun.Click += new EventHandler(abc);
                i++;

                
            }

so i need some property to set the text in ascending order.

Please use code tags when you post code. What would be wrong if instead of this

btnRun = new SimpleButton();
btnRun.Tag = rgn.DestinationFormId;

you did this

btnRun = new SimpleButton();
btnRun.TextAlign = MiddleLeft;
btnRun.Tag = rgn.DestinationFormId;

Now sort rgn.MenuDescription first and then add it to the Text property.

Edited 3 Years Ago by Reverend Jim: Fixed formatting

This article has been dead for over six months. Start a new discussion instead.