Windows Develop Bookmark and Share   
 index > Windows Forms General > Control the creation docked objects
 

Control the creation docked objects

Hello,

I want to create severalbuttons within another panel. These createdbuttons are used for a tuchscreen app.

Each Button reveices a DockStyle TOP. The problem is that the second created button comes above th first, and the thrid above the second. As the buttons are dynamically generated from a query i just can reverse my ordering and it works.

But i want to know if it is possible to create a button and dock it below an existing button, both with style top.

This is my code.

foreach (DataRow row in myDataTable.Rows)
{
SimpleButton sb = new SimpleButton();
sb.Text = row["PRDTYPE_NAME"].ToString();
sb.Height = ButtonHeight;
sb.Dock = DockStyle.Top;
sb.Parent = pcLeft;
sb.Image = imgFolder;
sb.Tag = Convert.ToInt32(row["PRDTYPE_UI"].ToString());
sb.Click += SelectBrandLevel;
}
Harry_Leboeuf  Thursday, September 28, 2006 10:02 AM

The docking order is given by the order of the controls in the Controls collection so the only thing you can do is to reverse the order of adding the buttons.

Mike Danes  Thursday, September 28, 2006 12:28 PM
You can also use either BringToFront or SendToBack methods after adding the control. I think in your case sb.BringToFront().
JRQ  Thursday, September 28, 2006 3:13 PM

You can use google to search for other answers

Custom Search

More Threads

• Read resource text file
• How to convert String value and assign it to timePicker?
• Checkbox always returns false
• Divide a form
• How do I trap the minimize and maximize and restore events in a windows form?
• how to change focus on several editbox'es by pressing 'enter' key
• Expand the treeview node while doing drag drop
• Scaling Windows Forms
• Can't choose label size
• error 0 filling treeview control