Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to add a close button on my tabpages.. so i add image to the tabpage..and check its position in the mouse down event for closing the tabpage..

but the image appears on the left side of tabpage header.. how can i move it to the right????
Posted

1 solution

Hi,

There is a way to move the image to the right. You have to add Paint Event of tab page
and get the graphics pointer. http://msdn.microsoft.com/en-us/library/system.windows.forms.control.onpaint.aspx[^]

C#
Graphics g = e.Graphics.
g.DrawImage(TestImage, new Rectangle(xDraw, yDraw, TestImageWidth,
TestImageHeight));


xDraw, and yDraw will get you the offset to move the image to the right.

Kind regards,
 
Share this answer
 
Comments
Ehtesam Ahmed 30-Sep-11 7:42am    
i m using dynamic tabpages... so i think i cant use paintevent of tabpage..
BobJanova 30-Sep-11 8:21am    
Of course you can. When you create the page, hook onto its Paint event

myNewTabPage.Paint += ...

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