综合编程

winform 在控件中添加PictureBox后又添加CheckBox

微信扫一扫,分享到朋友圈

winform 在控件中添加PictureBox后又添加CheckBox
0

// 在控件panel中添加PictureBox

private void SetPage(List<ExtenStatus> listdata)

{

this.panel2.Controls.Clear();

int row = 0;

for (int i = 0; i < listdata.Count; i++)

{

if (i % 8 == 0 && i != 0)

{

row++;

}

PictureBox pic = new PictureBox();

pic.Name = listdata[i].ExtenInfo.ToString(); //"唐" + i.ToString();

string callstates = SetValue.getStateStr(listdata[i].ExtenState);

pic.Tag = listdata[i].ExtenState;

Bitmap b = new Bitmap(Application.StartupPath + @"img" + AppDate.SetValue.getStatepic(listdata[i].ExtenState) + ".png");

pic.MouseClick += PicClick;

pic.Image = b;

pic.Size = new Size(110, (panel2.Height / 9 – 1));

//pic.Location = new Point(30 + i % 8 * (pbw / 12), 30 + row * 60);

pic.Location = new Point(30 + i % 8 * (pbw / 12), 30 + row * (panel2.Height / 9));

Graphics gra = Graphics.FromImage(pic.Image);//要进行处理的图片对象

SolidBrush brush = new SolidBrush(Color.Black);//初始化画笔

AddChechBox(pic);

gra.DrawString(GetName(RemoveAt(listdata[i].ExtenInfo.ToString())) + "rn" + callstates, DefaultFont, brush, 60, 5);//处理图片

pic.Refresh();//

this.panel2.Controls.Add(pic);

}

}

// 在PictureBox中添加CheckBox

private void AddChechBox(PictureBox picbox)

{

CheckBox ck = new CheckBox();

string comid = picbox.Name;

ck.Name = comid;

ck.AutoSize = true;

ck.Location = new System.Drawing.Point(-1, -1);//位置自定义

picbox.Controls.Add(ck);

}

// 取值

foreach (Control o in mc.panel2.Controls)

{

if (o is PictureBox)

{

foreach (Control c in o.Controls)

{

if (c is CheckBox)

{

if (((CheckBox)c).Checked == true)

{   

//你的代码

}

}

}

}

}

阅读原文...


博客园精华区

Playing with Software Defined Radio

上一篇

Journalist Carole Cadwalladr says ‘the gods of Silicon Valley’ have broken democracy

下一篇

您也可能喜欢

评论已经被关闭。

插入图片
winform 在控件中添加PictureBox后又添加CheckBox

长按储存图像,分享给朋友