【问题标题】:Assign display value from a combo box to another text将组合框中的显示值分配给另一个文本
【发布时间】:2016-01-07 07:54:23
【问题描述】:

我有代码来显示组合框,例如

da.Fill(ds1, "HDTYPE");
comboHD.DisplayMember = "hw_define";
comboHD.ValueMember = "hwd_Id";
comboHD.DataSource = ds1.Tables["HDTYPE"];

问题是我想将选定的文本(即hw_define)分配给另一个文本字段以打印数据,将hwd_Id 分配给数据库以保存数据。我可以使用hwtype.SelectedValue 获得选定的ID(hwd_id)。 但是我怎样才能被选中 - hw_define text 来分配另一个文本框?

【问题讨论】:

  • 在 comboHD 上的 selectedIndex 上设置文本框值
  • comboHD.Text 应该这样做。
  • 谢谢@Irshad,成功了
  • 我会将其添加为答案。请标记为已接受。

标签: c# winforms combobox selectedvalue


【解决方案1】:

您可以使用comboHD.Text 让他的值显示在组合框中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-04
    • 2020-07-13
    • 2018-11-04
    • 1970-01-01
    相关资源
    最近更新 更多