2010-02-26 4 views
1

필자는 checkedListBox에 Fname 및 ID를 바인드했습니다. checkedListBox에서 Frame 만 볼 수 있습니다. checkedListBox (일부 프레임)에서 일부 항목을 선택하려고합니다.checkedListBox 및 SQL 쿼리

버튼을 누르면 - 내가 선택한 목록 (내가 선택한 ID 목록)을보고 싶습니다.

나는이 같은 checkedListBox를 작성했다 : 나는 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; 

는 내 질문 - 내가 어떻게 ID의 목록을 얻을 않음 - ValueMember을 ??

답변

1

SelectedItemSelectedItems은 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); 
} 

약간 수정.