日期:2014-05-18 浏览次数:21276 次
TextBox txtbox = new TextBox();
txtbox.Parent = this;
txtbox.Left = 0;
txtbox.Top = 0;
ComboBox combox = new ComboBox();
combox.Parent = this;
combox.Left = txtbox.Right + 10;
combox.Top = 0;
combox.Visible = false;
txtbox.Tag = combox;
txtbox.TextChanged += new EventHandler(
delegate(object obj, EventArgs ex)
{
((ComboBox)((TextBox)obj).Tag).Visible = !string.IsNullOrEmpty(((TextBox)obj).Text);
}
);
------解决方案--------------------
ComboBox cbo = new ComboBox();
cbo.DropDownStyle = ComboBoxStyle.DropDownList;
cbo.Location = new System.Drawing.Point(73, 171);
cbo.Name = "cboCont";
this.Controls.Add(cbo);
绑定combobox
------解决方案--------------------
有一个文本框,有一个下拉框,需要当1文本框中有文字的时候,就动态在他后面出来一个下拉框
完全不需要动态,动态的事件涉及到页面生命周期,很不好操作。
页面上隐藏掉下拉框。你只需要的文本框的TextChange事件判断,
if(!string.isnullorEmpty(text))
{
dropdownlist.visible = true; //设置下拉框显示。
}