|
-
Jul 27th, 2004, 08:35 AM
#8
Thread Starter
Addicted Member
Urgh... I still can't get this right. I tried the suggested events for calling the DrawOnTheControl function, but it still won't paint it when the control first appears. I tried instead to draw the borders when the form is initialised or resize, for example:
Code:
private void frmMain_Load(object sender, System.EventArgs e)
{
drawBorder (textBox1, Color.Blue);
}
private void drawBorder (Control ctrl, Color colour)
{
Graphics g = ctrl.CreateGraphics ();
Pen p = new Pen (colour, 2);
g.DrawRectangle (p,
ctrl.ClientRectangle.Left, ctrl.ClientRectangle.Top,
ctrl.ClientRectangle.Width, ctrl.ClientSize.Height);
g.Flush ();
g.Dispose ();
}
It works ok with the resize event (although you can still see 'trails' of the original black colour), but the Load function doesn't work at all - I'm guessing this is because the control hasn't been loaded yet.
Is there not a better way to do this?
Also, while I've got the code posted, how can I pass the control in by reference? I've tried using 'ref' but it complains about me passing a TextBox rather a Control.
Thanks with your help so far, though
Using Visual Studio .NET 2005
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|