Combobox

hbszhtlxc 2008-12-29 02:27:19
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{

string strCH ;

strCH = comboBox1.Text.ToString();

string strcmdTxt = "Select Name From Item_Code_Finishing Where Family = 'CH '";

//string strcmdTxt = "Select Item_code + Name From Item_Code_Finishing Where Family = 'CH '";

SqlDataAdapter mySqlAdapter = new SqlDataAdapter(strcmdTxt, ClsDataAcc.conString);
DataSet ds = new DataSet();
mySqlAdapter.Fill(ds, "Item_Code_Finishing");
comboBox2.DataSource = ds.Tables["Item_Code_Finishing"];
//comboBox2.DisplayMember = "Name";
comboBox2.DisplayMember = "Item_code";


}

我想要 comboBox2.DisplayMember = "Item_code + Name"; Item_code + Name相加的结果(//string strcmdTxt = "Select Item_code + Name From Item_Code_Finishing Where Family = 'CH '";
)用此语句,则出现 comboBox2. text = System.Data.DataRowView
...全文
38 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
设备管理系统 2008-12-29
  • 打赏
  • 举报
回复
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{

string strCH ;

strCH = comboBox1.Text.ToString();

string strcmdTxt = "Select (Item_code + Name) t From Item_Code_Finishing Where Family = 'CH '";

SqlDataAdapter mySqlAdapter = new SqlDataAdapter(strcmdTxt, ClsDataAcc.conString);
DataSet ds = new DataSet();
mySqlAdapter.Fill(ds, "Item_Code_Finishing");
comboBox2.DataSource = ds.Tables["Item_Code_Finishing"];
comboBox2.DisplayMember = "t" ;
}
suners 2008-12-29
  • 打赏
  • 举报
回复
mark

111,130

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧