Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change border color of panel

Status
Not open for further replies.

JontyMC

Programmer
Nov 26, 2001
1,276
GB
Windows form question: How can I change the border color of a panel when the user clicks on it?

Jon

"There are 10 types of people in the world... those who understand binary and those who don't.
 
Code:
this.panel1.Click += new System.EventHandler(this.panel1_Click);
//...
private void panel1_Click(object sender, System.EventArgs e)
		{
			this.panel1.BorderStyle=System.Windows.Forms.BorderStyle.Fixed3D;

		}
obislavu
 
Thanks, but I need to change the border color, not the style.

Jon

"There are 10 types of people in the world... those who understand binary and those who don't.
 
Sorry for missunderstanding.
I think you have to implement a custom Panel class and override the OnPaint() method.
There use Region , Rectangle, Brush objects and Graphics.DrawRectangle() to draw the border with a desired pen.
obislavu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top