zoukankan
html css js c++ java
c#+winform+combobox+动态生成控件,根据选择的内容 Virus
根据combobox选择的内容生成控件,窗体添加一个combobox和一个panel,在panel中添加控件,方便添加其他控件之前可以清除以前的控件
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Text;
using
System.Windows.Forms;
using
System.Data.SqlClient;
namespace
WindowsApplication21
{
public
partial
class
Form1 : Form
{
public
Form1()
{
InitializeComponent();
}
private
void
Form1_Load(
object
sender, EventArgs e)
{
this
.comboBox1.Items.Add(
"
tcp
"
);
this
.comboBox1.Items.Add(
"
udp
"
);
}
private
void
comboBox1_SelectedIndexChanged(
object
sender, EventArgs e)
{
this
.panel1.Controls.Clear();
Label lbl
=
new
Label();
this
.panel1.Controls.Add(lbl);
lbl.Text
=
comboBox1.SelectedItem.ToString();
lbl.Name
=
"
lbl
"
+
lbl.Text;
lbl.Top
=
this
.panel1.Top;
lbl.Width
=
50
;
lbl.Height
=
20
;
TextBox tb
=
new
TextBox();
this
.panel1.Controls.Add(tb);
tb.Text
=
""
;
tb.Name
=
"
tb
"
+
lbl.Text;
tb.Top
=
lbl.Top;
tb.Left
=
lbl.Right
+
10
;
tb.Width
=
200
;
tb.Height
=
20
;
}
}
public
class
ListItem
{
private
string
textField;
public
string
TextField
{
get
{
return
textField; }
set
{ textField
=
value; }
}
private
string
valueField;
public
string
ValueField
{
get
{
return
valueField; }
set
{ valueField
=
value; }
}
}
//
下面绑定
}
【Blog】
http://virusswb.cnblogs.com/
【MSN】
jorden008@hotmail.com
【说明】转载请标明出处,谢谢
反馈文章质量,你可以通过快速通道评论:
查看全文
相关阅读:
VM 下增加磁盘空间
在APACHE服务器上的访问方式上去除index.php
1
数组累加兼eval性能测试
webstorm软件使用记录
gulp配置安装使用
jQuery方法笔记
搭建Grunt集成环境开发SASS
msysgit使用方法
十诫在天主教和新教之间的差别
原文地址:https://www.cnblogs.com/virusswb/p/1197695.html
最新文章
discuz 迁移 uc_server 报错
The timeout period elapsed prior to completion of the operation or the server is not responding.
微信小程序笔记
xmlns 与 targetNamespace 的解释
Ubuntu64 apache2+lvs+Keepalived
NPOI CellStyle 设置
mysql --initialize specified but the data directory has files in it
select2 多选设置默认值
VS 2015 IDE 不支持 MS SQL 2000 生成 dbml
软件体系架构在工作中的总结
热门文章
论设计模式在工作中的运用
论软件体系结构风格以及应用
论软件架构建模技术与应用
window dos 下批量删除docker 容器
svn中日志不展示解决方法记录
接口测试工具中 post请求如何传递多维数组
js常用阻止冒泡事件
设置本地cookie 存session 保持长期有效
身份证js正则
websocket 多聊天室功能
Copyright © 2011-2022 走看看