首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >checkedListBox和SQL查询

checkedListBox和SQL查询
EN

Stack Overflow用户
提问于 2010-02-26 15:07:43
回答 1查看 500关注 0票数 1

我已经将Fname和ID绑定到我的checkedListBox。我在checkedListBox中只看到了框架。我想在checkedListBox (一些框架)中选择一些项目。

当我按下按钮时-我想看到我选择的列表(我选择的ID列表)。

我是这样填充checkedListBox的:

代码语言:javascript
复制
 SQL = "select distinct TrapName,substr(TrapNum,1,4) from TrapTbl order by substr(TrapNum,1,4) ";
            adp = new OracleDataAdapter(SQL, Conn);
            dsView = new DataSet();
            adp.Fill(dsView, "TrapTbl");
            adp.Dispose();
            this.ListAtar.DataSource = dsView.Tables[0];
            this.ListAtar.DisplayMember = dsView.Tables[0].Columns[0].ColumnName;
            this.ListAtar.ValueMember = dsView.Tables[0].Columns[1].ColumnName;

我的问题是,当我从checkedListBox中选择一些项目并按下按钮时-如何获得ID列表- ValueMember?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-02-26 15:13:26

您将SelectedItemSelectedItems作为checkedListBox的属性。

来自MSDN的示例:

代码语言:javascript
复制
private void youbutton_Clicked(object sender, System.EventArgs e)
{
   // Get the currently selected item in the ListBox.
   string curItem = listBox1.SelectedItem.ToString();

   // Find the string in ListBox2.
   int index = listBox2.FindString(curItem);
   // If the item was not found in ListBox 2 display a message box, 
   // otherwise select it in ListBox2.
   if(index == -1)
      MessageBox.Show("Item is not available in ListBox2");
   else
      listBox2.SetSelected(index,true);
}

稍微修改了一下。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2339996

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档