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
【说明】转载请标明出处,谢谢
反馈文章质量,你可以通过快速通道评论:
查看全文
相关阅读:
SDPA: Toward a Stateful Data Plane in Software-Defined Networking
带状态论文粗读(一)
P4: Programming Protocol-Independent Packet Processors
P4论文粗读笔记(一)
A Survey on the Security of Stateful SDN Data Planes
stateful openflow------整理openstate原理以及具体应用
Software-Defined Networking A Comprehensive Survey(一)
互联网安全(二)
互联网安全(一)
分层网络模型(三)
原文地址:https://www.cnblogs.com/virusswb/p/1197695.html
最新文章
【转载】百度百科:FusionCube超融合
鲲鹏920的特性
ARM处理器、X86处理器和AI处理器的区别
块存储特性
SSD和HDD的区别
基于OceanStor Dorado V3存储之数据保护 Hyper 特性
基于OceanStor Dorado V3存储之精简高效 Smart 系列特性
在IT产品白皮书中遇到的缩略词
【转载】什么是NVMe?
SATA接口、PCI/PCIe、NVMe的介绍
热门文章
Android事件传递机制总结
JNI_day02
JNI_day01
Java对象实例化的过程
Android中数据缓存的处理
Android中Widget开发步骤
Android Studio在创建/导入项目的时候,一直处于building “XXX”gradle project info的解决办法
android中shape的使用介绍-2环形
看出每个应用程序最高可用内存是多少
根据现有Bitmap生成相同图案指定大小的新Bitmap
Copyright © 2011-2022 走看看