Windows Develop Bookmark and Share   
 index > Windows Forms General > BringToFront & SendToBack in an Editor for controls.
 

BringToFront & SendToBack in an Editor for controls.

Hi MSDN ,

I created an editor with controls at runtime saving & retrieving by storing the details of controls in csv .

Suppose if a Picturebox Control is WIth Location 100,100 and Size 200,200 and a Label Control with same size & Location are created .

Now i Set the Picturebox property to BRINGTOFRONT .and label is back to Picturebox . The user is able to see the PictureBox but not Label i saved .

Now in the order of creation of reading the file i got the Label last then it is Showing on Front rather than PictureBox.
Which is a Bug


May I know how to Store the BringToFront or SendToBack in my file and retrieve the Order Of Controls as it is like IN Visual Studio ..

Its IMPortant ...

Regards


VS
SilverPlate  Friday, May 29, 2009 1:38 PM

Whichever one is added first will be on top.

Here's where your confusion lies.... BringToFront is not a property, it's a method of the designer. When you use the designer and you right click on a control and select BringToFront, you're not really setting any property, you're changing the order in which the controls are added to the form. BringToFront moves the addition of that specific control to the top of the list, adding that control first, while SendToBack moves the addition of the control, via the this.Controls.Add method to the bottom of the list.

The answer is to add your controls to your form in order, from the foremost control to the backmost control.

this.Controls.Add(button);

this.Controls.Add(label);

The above two calls will ensure the button resides above the label. If those two lines were reversed, the label would reside on top of the button.


David Morton - http://blog.davemorton.net/ - @davidmmorton
David M Morton  Friday, May 29, 2009 2:08 PM
Hi David ,

I understand this one . but while the controls drag n drop on the form . I have to Undo / Redo , Cut /Copy /Paste , BringTofront,SendToback etc lot of activities.

Presently in the undo/redo custom i am not maintaining the Undo/Redo things.

So after doing all these controls How can i maintain a state of particular control.

Ex: If i am doing BringToFront / Then again sendtoback for single control. How can i know the back side of that particular control can come forward . How can i maintain the control info of the backward control that comes on TOP.

The Same with the multiple controls.How can i store this type of data related to controls BringToFront / SendToBack .

In my editor i am having the multiple controls drag n drop .(Custom application like VB Editor)

Like this one i am having the problem of maintaining the state of the particular control.

Regards,


VS
SilverPlate  Thursday, September 24, 2009 6:46 AM

You can use google to search for other answers

Custom Search

More Threads

• Error connecting to server when passing data to web page from windows app
• Property Grid
• KeyPreview Property Behavior Seemingly Inconsistent
• Windows Forms in VB 6.0
• Windows Application Problem
• Cross Thread operation not valid
• Equivalent code for infragistics combo box
• How to create the code into my own method but not InitializeComponent when add a my own compenent or control
• Convert money value to text.
• ToolTip and c#