heisetoufa 发表于 2013-1-27 05:12:42

c# winform pictureBox如何突出显示,放大并给pictureBox边框变色

感谢CSDN上的h_w_king帮忙解决问题
我按顺序4*4排了16个pictureBox,紧挨着

我现在想选中哪个pictureBox,就给哪个pictureBox突出显示,以告诉用户,你选择的是XX  pictureBox

放大并且给边框变色,这两个事件要一起用,不然无效
PictureBox old = null;      private void pictureBox2_Click(object sender, EventArgs e)      {            PictureBox p = (PictureBox)sender;            if (p == old) return;            if (old != null)            {                old.Width -= 10;                old.Height -= 10;                old.Location = new Point(old.Location.X + 5, old.Location.Y + 5);            }            old = p;            p.Width += 10;            p.Height += 10;            p.Location = new Point(p.Location.X - 5, p.Location.Y - 5);            p.BringToFront();                   }      private void pictureBox2_Paint(object sender, PaintEventArgs e)      {            PictureBox p = (PictureBox)sender;            if (p == old)            {                Pen pp = new Pen(Color.Red);                e.Graphics.DrawRectangle(pp, e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle.X + e.ClipRectangle.Width - 1, e.ClipRectangle.Y + e.ClipRectangle.Height - 1);            }      } 
黑色头发  http://heisetoufa.iteye.com
页: [1]
查看完整版本: c# winform pictureBox如何突出显示,放大并给pictureBox边框变色