动态添加控件
2016-06-16 20:20
417 查看
for (int i = 0; i < FlowPanel_Station.Controls.Count; i++)
{
Panel pan = new Panel();
pan = (Panel)FlowPanel_Station.Controls[i];
string[] str = new string[8];
str[0] = "站点名称:";
str[1] = "连接状态:";
str[2] = "监听端口:";
str[3] = "更新时间:";
str[4] = "";
str[5] = "";
str[6] = "";
str[7] = "";
Label[] label = new Label[8];
Point[] point = new Point[8];
for (int k = 0; k < 8; k++)
{
if (k < 4)
{
label[k] = new Label();
label[k].Text = str[k];
label[k].Width = 70;
pan.Controls.Add(label[k]);
int x = pan.Location.X + 5;
int y = pan.Location.Y + label[k].Height * k + 10;
point[k] = new Point(x, y);
label[k].Location = point[k];
}
else
{
label[k] = new Label();
label[k].Text = str[k];
label[k].Width = 70;
pan.Controls.Add(label[k]);
int x = pan.Location.X + label[k - 4].Width + 5;
int y = pan.Location.Y + label[k - 4].Height * (k - 4) + 10;
point[k] = new Point(x, y);
label[k].Location = point[k];
}
}
}
int a = Convert.ToInt32(SqlHelper.ExecuteScalar(CommandType.Text, "select count(*) from Objects", null));
DataTable dt = new DataTable();
dt = SqlHelper.GetDataSet(CommandType.Text, "select ObName,ObWorker from Objects", null).Tables[0];
IList<Objects> ob = ModelConvertHelper<Objects>.ConvertToModel(dt);
DataRow dr=dt.NewRow();
工作流程管理.项目分类[] cos = new 工作流程管理.项目分类[a];
for(int i=0;i<=a;i++)
{
cos[i] = new 工作流程管理.项目分类();
string va=dt.Rows[i]["ObName"].ToString();
cos[i].la.Text = va;
flowLayoutPanel1.Controls.Add(cos[i]);
}
{
Panel pan = new Panel();
pan = (Panel)FlowPanel_Station.Controls[i];
string[] str = new string[8];
str[0] = "站点名称:";
str[1] = "连接状态:";
str[2] = "监听端口:";
str[3] = "更新时间:";
str[4] = "";
str[5] = "";
str[6] = "";
str[7] = "";
Label[] label = new Label[8];
Point[] point = new Point[8];
for (int k = 0; k < 8; k++)
{
if (k < 4)
{
label[k] = new Label();
label[k].Text = str[k];
label[k].Width = 70;
pan.Controls.Add(label[k]);
int x = pan.Location.X + 5;
int y = pan.Location.Y + label[k].Height * k + 10;
point[k] = new Point(x, y);
label[k].Location = point[k];
}
else
{
label[k] = new Label();
label[k].Text = str[k];
label[k].Width = 70;
pan.Controls.Add(label[k]);
int x = pan.Location.X + label[k - 4].Width + 5;
int y = pan.Location.Y + label[k - 4].Height * (k - 4) + 10;
point[k] = new Point(x, y);
label[k].Location = point[k];
}
}
}
int a = Convert.ToInt32(SqlHelper.ExecuteScalar(CommandType.Text, "select count(*) from Objects", null));
DataTable dt = new DataTable();
dt = SqlHelper.GetDataSet(CommandType.Text, "select ObName,ObWorker from Objects", null).Tables[0];
IList<Objects> ob = ModelConvertHelper<Objects>.ConvertToModel(dt);
DataRow dr=dt.NewRow();
工作流程管理.项目分类[] cos = new 工作流程管理.项目分类[a];
for(int i=0;i<=a;i++)
{
cos[i] = new 工作流程管理.项目分类();
string va=dt.Rows[i]["ObName"].ToString();
cos[i].la.Text = va;
flowLayoutPanel1.Controls.Add(cos[i]);
}
相关文章推荐
- mysql远程连接
- 数据结构(Splay平衡树):HAOI2008 排名系统
- 二分+DP HDU 3433 A Task Process
- iOS常用define宏定义
- Android Sax解析XML出现空值或脏数据的解决方案
- 风靡欧洲杯的足球手环?
- LeetCode刷题系列(十)Dynamic Programming(3)补充
- Codeforces Round #357 (Div. 2) Runaway to a Shadow
- 四月
- java导出word模板
- C++面向对象中的向上转换 向下转换 以及OOP相关的类型转换
- centos的软件安装方法rpm和yum
- LeakDiag使用手记
- golang 构建web应用
- JS中的this好神奇,都把我弄晕了
- [ARM] [linux master] 调试技术001 GDB-Advanced-001 Code Dump 的调试
- MFC中stdafx.h是什么意思?
- linux下yum安装及配置
- jsoup数据抓取学习
- 2.实现一个最简单的COM