我已经将Fname和ID绑定到我的checkedListBox。我在checkedListBox中只看到了框架。我想在checkedListBox (一些框架)中选择一些项目。
当我按下按钮时-我想看到我选择的列表(我选择的ID列表)。
我是这样填充checkedListBox的:
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?
发布于 2010-02-26 15:13:26
您将SelectedItem和SelectedItems作为checkedListBox的属性。
来自MSDN的示例:
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);
}稍微修改了一下。
https://stackoverflow.com/questions/2339996
复制相似问题