日期:2014-05-18 浏览次数:21164 次
private void c_Click(object sender, System.EventArgs e) { int n=0; PictureBox p = sender as PictureBox; this.lVw .SelectedItems .Clear (); foreach(ListViewItem item in this.lVw.Items) { if( item.SubItems [n].Text==p.Tag.ToString ()) { this.lVw.Items[n].Selected=true; this.lVw.Focus (); break; } ++n; } }
public class newPictureBox : PictureBox { public object newTag; public object NewTag { get { return NewTag; } set { NewTag = value; } } } private void c_Click(object sender, System.EventArgs e) { int n=0; PictureBox p = sender as PictureBox; this.lVw .SelectedItems .Clear (); p.Image =null; p.BackgroundImage =Image.FromFile (Application.StartupPath +@"\背景\4.jpg"); foreach(ListViewItem item in this.lVw.Items) { if( item.SubItems [0].Text==p.vewTag.ToString ()) //这里我不知道你原来picturebox的tag干什么用了 { this.lVw.Items[n].Selected=true; this.lVw.Focus (); break; } ++n; } } private void setTag(Control cons) { foreach (Control con in cons.Controls ) { //if (con is PictureBox) continue;这里已经不需要拉。 con.Tag = con.Width +":" + con.Height + ":" + con.Left + ":" + con.Top + ":" + con.Font.Size; if (con.Controls.Count > 0) { setTag(con); } } } private void setConstrols(float newx,float newy,Control cons) { foreach (Control con in cons .Controls ) { string[] mytag = con.Tag.ToString().Split(new char[] { ':' }); float a = Convert.ToSingle(mytag[0]) * newx; con.Width = (int)a; a=Convert.ToSingle(mytag[1]) * newy; con.Height = (int)(a); a=Convert.ToSingle(mytag[2]) * newx; con.Left = (int)(a); a=Convert.ToSingle(mytag[3]) * newy; con.Top = (int)(a); Single currentSize = Convert.ToSingle (mytag[4]) * newy; con .Font =new Font (con.Font .Name ,currentSize,con.Font .Style ,con.Font .Unit