在网上找了一段代码,主要是实现picturebox选中效果。但是当pictruebox处于选中状态时,只要往里面放带边框的窗体,就会出项边框。
收回下拉列表的时候就变这样了:
各位大神帮忙啊。 PictureBox old = null;
private void PictureBox_MouseDown(System.Object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
PictureBox pic = (PictureBox)(sender);
if (pic == old) return;
if (old != null)
{
old.Width -= 10;
old.Height -= 10;
old.Location = new Point(old.Location.X + 5, old.Location.Y + 5);
}
old = pic;
pic.Width += 10;
pic.Height += 10;
pic.Location = new Point(pic.Location.X - 5, pic.Location.Y - 5);
pic.BringToFront();
}
}
private void pictureBox_Paint(object sender, PaintEventArgs e)
{
PictureBox p = (PictureBox)sender;
if (p == old)
{
Pen pp = new Pen(Color.Yellow);
pp.Width = 5;
e.Graphics.DrawRectangle(pp, e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle.X + e.ClipRectangle.Width - 1, e.ClipRectangle.Y + e.ClipRectangle.Height - 1);
}
}
收回下拉列表的时候就变这样了:
各位大神帮忙啊。 PictureBox old = null;
private void PictureBox_MouseDown(System.Object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
PictureBox pic = (PictureBox)(sender);
if (pic == old) return;
if (old != null)
{
old.Width -= 10;
old.Height -= 10;
old.Location = new Point(old.Location.X + 5, old.Location.Y + 5);
}
old = pic;
pic.Width += 10;
pic.Height += 10;
pic.Location = new Point(pic.Location.X - 5, pic.Location.Y - 5);
pic.BringToFront();
}
}
private void pictureBox_Paint(object sender, PaintEventArgs e)
{
PictureBox p = (PictureBox)sender;
if (p == old)
{
Pen pp = new Pen(Color.Yellow);
pp.Width = 5;
e.Graphics.DrawRectangle(pp, e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle.X + e.ClipRectangle.Width - 1, e.ClipRectangle.Y + e.ClipRectangle.Height - 1);
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货