private void createBoxes() { int count = 134; int column = 11; for (int i = 0; i < count; i++) { FaceBox box = new FaceBox(i); box.Location = new Point(i % column * 30, i / column * 30); box.MouseHover += box_MouseHover; this.Controls.Add(box); box.Selected += delegate(int faceID) { if (this.AddFace != null) { this.AddFace("Face_" + faceID); } this.Hide(); }; } this.Width = 30 * column + 6;//6为两边框宽 this.Height = (count / column + (count % column == 0 ? 0 : 1)) * 30 + 3; }
private void box_MouseHover(object sender, EventArgs e) { FaceBox box = sender as FaceBox; picView.Visible = true; picView.Location = box.Location; picView.Image = (Image)Properties.Resources.ResourceManager.GetObject("Face_" + box.faceID); picView.Tag = box.faceID; }