Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Anyone can help me?Example,in my form,i have a picturebox and some buttons.When my program run,i want to replace the buttons,which are on form by some new buttons.But there is a problem.the new buttons appear behind picturebox.What must i do?
Posted

Try:
C#
Button b = new Button();
b.Text = "New button";
b.Location = new Point(myPictureBox.Left - 5, myPictureBox.Top - 5);
Controls.Add(b);
b.BringToFront();
 
Share this answer
 
BringToFront() method--to bring the button to front
eg:-button1.BringToFront();

Hide() method--to hide button(to hide previous button).
eg:-button1.Hide();

Show() method--to show button(to show new button).
eg:-button1.Show();


Location.X and Location.Y --to get and set location.
get location of previous button and set it to new button.


hope this solves ur problem


-The Guardian.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900