In my C # Winform (VS 2010 / C # /. Net 3.5) I created a button in the designer. I want to move and resize this button elsewhere based on user preferences when this form is run.
In my form load event, I have the following code to move and resize the button:
btnShare.Location = new System.Drawing.Point(16, 496);
btnShare.Margin = new System.Windows.Forms.Padding(4);
btnShare.Size = new System.Drawing.Size(408, 126);
All the code for creating the button is the * .designer.cs file for this particular form.
The problem is this: when the form loads, I see a button in it of a new location based on the three lines of code above. But then, when the form is loaded and goes through all the events, the button will return to its original location, which is located in the * .designer.cs InitalizeComponent () method.
I donβt want to output the code from the * .designer.cs file and put it only in the .cs file, because I still want to see the button in the designer when I work on the form design.
I just want to move and resize the button if the user has this option enabled when the form loads.
How can I do this, since .Net seems to draw buttons on my form after the load event has been processed, thus moving the button back to its original location?
source
share