How can I do it so that I can specify which border I would like to
appear on a panel? Say for example on a panel I want all sides except
the right side to be drawn?

Re: Specifying borders for a panel by Mick

Mick
Sat Jul 16 03:20:27 CDT 2005

<marc.cueto@gmail.com> wrote in message
news:1121488729.601787.206500@f14g2000cwb.googlegroups.com...
> How can I do it so that I can specify which border I would like to
> appear on a panel? Say for example on a panel I want all sides except
> the right side to be drawn?
>

Have a look at the ControlPaint.DrawBorder and DrawBorder3D methods.

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html



Re: Specifying borders for a panel by Herfried

Herfried
Sat Jul 16 07:20:05 CDT 2005

<marc.cueto@gmail.com> schrieb:
> How can I do it so that I can specify which border I would like to
> appear on a panel? Say for example on a panel I want all sides except
> the right side to be drawn?

You may want to override the control's 'OnPaint' method and draw the borders
there using appropriate methods of the 'ControlPaint' class.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


Re: Specifying borders for a panel by marc

marc
Sun Jul 17 14:19:08 CDT 2005

Thank you all for replying. I managed to get it going using this code
sample:
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);

Rectangle borderRectangle = this.ClientRectangle;
borderRectangle.Inflate(-10, -10);
ControlPaint.DrawBorder(e.Graphics, borderRectangle,
System.Drawing.Color.Black, 1,
System.Windows.Forms.ButtonBorderStyle.Solid,
System.Drawing.Color.Black, 1,
System.Windows.Forms.ButtonBorderStyle.Solid,
System.Drawing.Color.Black, 1,
System.Windows.Forms.ButtonBorderStyle.Solid,
System.Drawing.Color.Black, 1,
System.Windows.Forms.ButtonBorderStyle.Solid);
}
I have one last question though. The top, left and bottom borders
connect fine but the left border seems to be a little off. The top and
bottom borders run past the right border by about 1 pixel. What is the
problem?


Re: Specifying borders for a panel by Mick

Mick
Mon Jul 18 04:31:03 CDT 2005

That would appear to be a bug.

You can workaround it by setting the Clip Region of the graphics object to
your borderRectangle.

> borderRectangle.Inflate(-10, -10);

e.Graphics.Clip = new Region(borderRectangle);
> ControlPaint.DrawBorder(e.Graphics, borderRectangle,

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html


<marc.cueto@gmail.com> wrote in message
news:1121627948.505285.247210@f14g2000cwb.googlegroups.com...
> Thank you all for replying. I managed to get it going using this code
> sample:
> protected override void OnPaint(PaintEventArgs e)
> {
> base.OnPaint(e);
>
> Rectangle borderRectangle = this.ClientRectangle;
> borderRectangle.Inflate(-10, -10);
> ControlPaint.DrawBorder(e.Graphics, borderRectangle,
> System.Drawing.Color.Black, 1,
> System.Windows.Forms.ButtonBorderStyle.Solid,
> System.Drawing.Color.Black, 1,
> System.Windows.Forms.ButtonBorderStyle.Solid,
> System.Drawing.Color.Black, 1,
> System.Windows.Forms.ButtonBorderStyle.Solid,
> System.Drawing.Color.Black, 1,
> System.Windows.Forms.ButtonBorderStyle.Solid);
> }
> I have one last question though. The top, left and bottom borders
> connect fine but the left border seems to be a little off. The top and
> bottom borders run past the right border by about 1 pixel. What is the
> problem?
>