0

i want to auto select first list box vale how

private void check_Click(object sender, EventArgs e)
        {
           
             for (int x = 0; x < listBox1.Items.Count; x++)
   {
      // Determine if the item is selected.
      
      if(listBox1.GetSelected(x) == true)
      {
         // Deselect all items that are selected.
         listBox2.SetSelected(x,true);
      }
                 SqlDataAdapter adap = new SqlDataAdapter("SELECT Bno from win_number where Bno between '"+listBox1.SelectedItem+"' and '"+listBox2.SelectedItem+"'" , con);
                 DataSet ds = new DataSet();
                 //DataTable dt = new DataTable();
                 adap.Fill(ds);
                 if (ds.Tables[0].Rows.Count == 0)
                 {
                     label3.Text = "sory";
                 }
                 else
                 {
                     label3.Text = ds.Tables[0].Rows[0][0].ToString();
                 }
   }

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by dnanetwork
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.