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
【说明】转载请标明出处,谢谢
反馈文章质量,你可以通过快速通道评论:
查看全文
相关阅读:
Ext文本框添加清除图标,
gird鼠标移动显示tip
shapefile文件导入mysql数据库
百度、高德、谷歌、火星、wgs84(2000)地图坐标相互转换的JS实现
POSTGIS修复错误数据
地图瓦片切片方案
mapbox.gl源码解析——基本架构与数据渲染流程
高斯克吕格与地理坐标相互转换算法(JS版本)
mysql空间扩展对比postgis
从maven central下载javax.media.jai_core:1.1.3时出错
原文地址:https://www.cnblogs.com/virusswb/p/1197695.html
最新文章
docker入门使用教程
Nginx反向代理负载均衡配置
【Keepalived+MySQL】MySQL双主互备+高可用
【面筋】总结
【Jenkins】Jenkins的安装与配置
【LVS】简介与说明
【MySQL】MySQL备份和恢复
【Open-Falcon】Linux下安装Open-Falcon
【ZABBIX】Linux下安装ZABBIX
【Shell】使用shell打印菜单,一键安装Web应用
热门文章
【Linux】tcpdump命令详解
【MySQL】MySQL基础
ionic 头部隐藏 ios问题
css3 对话样式
html5 流程条
html5 table
extjs 手风琴布局样式修改
ext修改文本样式
mysql(1) 库和表的处理
数据转换
Copyright © 2011-2022 走看看