下拉框实现的问题???? 假如我表中有两个字段 table A ID Name 我点击下拉框的时候,这表中两个字段的我都能看到、、 我输入 ID 的时候,当我鼠标离开时候,它就会显示对应ID的Name 请问这个怎么来实现 谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你绑定DDL的时候把ID+Name绑定给DataTextField,ID绑定给DataValueField然后DDL选的时候触发DDL的SelectedIndexChanged事件private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e) { int selectnum=this.DropDownList1.SelectedIndex; this.DropDownList1.Items.Clear(); for(int i=0;i<dt.Rows.Count;i++) { if(i!=selectnum) { this.ddlBigSort.Items.Add(new ListItem(dt.Rows[i]["ID"].ToString()+dt.Rows[i]["Name"].ToString(),dt.Rows[i]["ID"].ToString())); } else { this.ddlBigSort.Items.Add(new ListItem(dt.Rows[i]["Name"].ToString(),dt.Rows[i]["ID"].ToString())); } } } 参考一下 http://www.codeproject.com/KB/combobox/DotNetMultiColumnComboBox.aspx http://www.codeproject.com/KB/combobox/MultiColComboSugtionBox.aspx 额代码里面DDL的名字写错了都改成这样 private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e) { int selectnum=this.DropDownList1.SelectedIndex; this.DropDownList1.Items.Clear(); for(int i=0;i<dt.Rows.Count;i++) { if(i!=selectnum) { this.DropDownList1.Items.Add(new ListItem(dt.Rows[i]["ID"].ToString()+dt.Rows[i]["Name"].ToString(),dt.Rows[i]["ID"].ToString())); } else { this.DropDownList1.Items.Add(new ListItem(dt.Rows[i]["Name"].ToString(),dt.Rows[i]["ID"].ToString())); } } } 最大值和最小值 XML问题,请高手们帮忙!SelectSingleNode()查不到值 打了sp1的vs2005,工具箱依然无法显示自定义控件 MDI窗体中的属性BackgroudImage设置了图片,我想设为拉伸怎么搞? ini多行文件的读取请教!!!!!!!!!!!!!!!!!!!! c#如何接收dll返回字符串,各位侠客请进 能否在c#里调用Windows 的API 请教一个正则表达式 wpf 添加checkbox 多选 在C#中如何实现延时。。。 窗体和xml的问题,急(C#,vs2005) 下拉框实现的问题????
然后DDL选的时候触发DDL的SelectedIndexChanged事件
private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
int selectnum=this.DropDownList1.SelectedIndex;
this.DropDownList1.Items.Clear();
for(int i=0;i<dt.Rows.Count;i++)
{
if(i!=selectnum)
{
this.ddlBigSort.Items.Add(new ListItem(dt.Rows[i]["ID"].ToString()+dt.Rows[i]["Name"].ToString(),dt.Rows[i]["ID"].ToString()));
}
else
{
this.ddlBigSort.Items.Add(new ListItem(dt.Rows[i]["Name"].ToString(),dt.Rows[i]["ID"].ToString()));
}
}
}
http://www.codeproject.com/KB/combobox/MultiColComboSugtionBox.aspx
private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
int selectnum=this.DropDownList1.SelectedIndex;
this.DropDownList1.Items.Clear();
for(int i=0;i<dt.Rows.Count;i++)
{
if(i!=selectnum)
{
this.DropDownList1.Items.Add(new ListItem(dt.Rows[i]["ID"].ToString()+dt.Rows[i]["Name"].ToString(),dt.Rows[i]["ID"].ToString()));
}
else
{
this.DropDownList1.Items.Add(new ListItem(dt.Rows[i]["Name"].ToString(),dt.Rows[i]["ID"].ToString()));
}
}
}