从组合框中选择两个值

时间:2013-09-12 08:02:34

标签: vb.net vb.net-2010

我有以下SP:

ALTER procedure [dbo].[selectService]
as
begin
     select cl_mt,cl_cl_id,cl_description from REF_CLIENT_TABLE
end

我用它来填充我的组合框:

        With service_combo
        .DataSource = serviceTable
        .DisplayMember = "cl_description"
        .ValueMember = "cl_mt"
        .SelectedIndex = 0
        .SelectedValue = serviceTable.Rows("cl_mt")
    End With

有没有办法能够选择2个值?因为我需要选择“cl_mt”和“cl_id”

1 个答案:

答案 0 :(得分:0)

您可以通过将基于表达式的列添加到原始表来执行此操作:

  serviceTable.Columns.Add(New DataColumn("binding", GetType(String),
                                                    "cl_mt + '|' + cl_id"))

  With service_combo
      .DataSource = serviceTable
      .DisplayMember = "cl_description"
      .ValueMember = "binding"
      ...
  End With

当您现在查询service_combo.SelectedValue时,您将获得以1|2形式返回的值;这将是您的cl_mt字段,后跟您的cl_id字段。