Click here to Skip to main content
15,921,062 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am creating windows application in which i have label control on bottom of the page. i want draw rectangale on label control. how can i do that ?
Posted
Comments
[no name] 2-Aug-12 9:30am    
Well.... you would probably call the DrawRectangle function to draw a rectangle....
efkah 2-Aug-12 9:41am    
WinForm or WPF?
Kenneth Haugland 2-Aug-12 9:53am    
Cant be WPF, wasnt available in .NET 2.0...
efkah 3-Aug-12 4:48am    
oh, im sorry.

If you actually want to draw ON the label control, then you need to construct a class derived from Label and override the OnPaint method:
C#
protected override void OnPaint(PaintEventArgs e)
    {
    base.OnPaint(e);
    Rectangle rect = new Rectangle(0,0, Width, Height);
    rect.Inflate(-5, -5);
    e.Graphics.FillRectangle(Brushes.Blue, rect);
    }
 
Share this answer
 
If you see my links I pasted in the answer here:
how to create line in panel in Location Arbitrary ?[^]

You'll have your answer :)
 
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