// comboBox 取值问题
// A: 在属性 Iitems 添加项
//
// CobShow.SelectedIndex 选择项的索引
// CobShow.SelectedItem 选择项的文本
// CobShow.SelectText 空值
// CobShow.SelectValue 报错...
// CobShow.Items[CobShow.SelectedIndex].ToString() 选择项的文本
//
// B:在程序中添加 CobShow.Item.Add() 结果和上面一样
//
//
// C:动态绑定数据
//
// CobShow.SelectedIndex 选择项的索引
// CobShow.SelectedItem System.DataRow.DefaultView
// CobShow.SelectText 空值
// CobShow.SelectValue 选择项的 VALUE 值
// CobShow.Text 选择项的 文本 值
// CobShow.Items[CobShow.SelectedIndex].ToString() System.DataRow.DefaultView
经测试我总结出来,结果同上一样:
VS.NET 2003中语法如下:
this.comboBox1.DataSource=ExecuteDataSet("select * from socut_data").Tables[0];//ExecuteDataSet返回一个DataSet;
this.comboBox1.DisplayMember="s_id";
this.comboBox1.ValueMember="s_id";
VS.NET 2005中语法如下:
this.comboBox1.DisplayMember="s_id";
this.comboBox1.ValueMember="s_id";
this.comboBox1.DataSource=ExecuteDataSet("select * from socut_data").Tables[0];//ExecuteDataSet返回一个DataSet;
comboBox控件SelectedIndexChanged时的取值问题
最新推荐文章于 2024-11-14 22:31:12 发布