imagebutton in centre
hi this is kavita
I want to show a imagebutton always in the middle in the screen my code is:
it is fine when page load but when i click button the page length increase but still button on the same location i want it to be always centre of screen like alert box always generate at centre.
any idea please write to me.
Jan MontanoPosted Aug 1, 2007, 2:10 AM
There's something wrong with your post. Can't ready the paragraph clearly. But if I understand it correctly, you're just not sure where to insert your code. You could insert it on the form's resize eventhandler.
First declare an event handler for the form resize. either on page load or initalizeComponent.
this.Resize += new EventHandler(Form1_Resize);
Then insert code in Form1_Resize method
void Form1_Resize(object sender, EventArgs e)
{
}
kavitaPosted Aug 1, 2007, 1:44 AM
Jan MontanoPosted Jul 31, 2007, 6:40 AM
You're screen code is?
I'm not sure if this is what you want, but if you want a control to be displayed at the center, you should get half the dimension of the container and subtract half the dimension of your control.
button2.Top = Height/2 - button2.Height/2;
button2.Left = Width/2 - button2.Width/2;
Regards,
Jan