Trouble in getting combobox populated in windows form!


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 1 of 1

Thread: Trouble in getting combobox populated in windows form!

Hybrid View

  1. #1
    Join Date
    Dec 2004
    Location
    Chicago, IL
    Posts
    11

    Question Trouble in getting combobox populated in windows form!

    Hi experts,

    I want to populate a combobox in windows form in vb.net, but I am having trouble to get it right, here is my code:

    Private Sub cboTALXChkDt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboTALXChkDt.Click
    cboTALXChkDt.Items.Clear()
    Dim cmdCheckDate As New SqlCommand
    Dim dtrCheckDate As SqlDataReader
    Dim conGPDb As New SqlClient.SqlConnection
    conGPDb.ConnectionString = "....................."
    With cmdCheckDate
    .Parameters.Clear()
    .CommandText = "SELECT DISTINCT CHEKDATE FROM UPR30300 WHERE YEAR1 = 2006 ORDER BY CHEKDATE"
    .Connection = conGPDb
    End With
    conGPDb.Open()
    dtrCheckDate = cmdCheckDate.ExecuteReader()

    While dtrCheckDate.Read()
    cboTALXChkDt.Items.Add(dtrCheckDate("CHEKDATE"))
    End While
    cboTALXChkDt.SelectedIndex = 0
    dtrCheckDate.Close()
    End Sub
    ------------------------------------------

    1. When it's populated, the name of combobox shows up in the box, followed by the items. How to prevent this name of combobox showing up in the box when it's populated? (the first item gets populated after I clicked the dropdown arrow).
    2. It shows only one item for the first time I clicked the dropdown arrow of combobox, but the 2nd time I click it, it populates more items to view.....I need it to be populated 10 items a time, so Any suggestion?

    Please help. Thank you.
    Last edited by JenHu; 03-02-2006 at 04:36 PM.

Similar Threads

  1. How to display a form from Windows Service
    By Sandeep Uppal in forum .NET
    Replies: 6
    Last Post: 07-10-2003, 05:59 AM
  2. Using windows explorer in my C# form
    By Fred in forum .NET
    Replies: 1
    Last Post: 02-12-2003, 11:46 PM
  3. Windows Form Bug
    By Beginner in forum .NET
    Replies: 4
    Last Post: 08-11-2001, 10:31 AM
  4. new browser windows form applets
    By jake in forum Java
    Replies: 1
    Last Post: 04-13-2001, 02:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center