Can someone tell me how to add an additional item to a combobox that is bound to a datatable?
I have populated the ComboBox with data from table

sSQLCbo = "SELECT region.ID, region.name FROM [STORES] ORDER BY store.ID"
        Dim ds As New DataSet

        da = New OleDb.OleDbDataAdapter(sSQLCbo, con)
        da.Fill(dt)

        con.Close()

        ComboBox1.DisplayMember = "Region"
        ComboBox1.ValueMember = "id"
        ComboBox1.DataSource = dt

Now I want to add an additional item "All Regions" so I can use this as part of a future query using the ComboBox SelectedIndexChanged.

U need to add the item to ur dt before setting the data and value member. or Edit ur Query to select All region as first item

Pgmer, thanks friend...

I put the following code between the Connection.Close and the ComboBox1.DisplayMember and it works fine now. Didn't like the idea of messing with my Query; seems a little sensitive at times.

con.Close()

        Dim dr As DataRow
        dr = dt.Rows.Add
        dr("ID") = 0
        dr("storename") = "-ALL STORES-"
        dr("storeid") = 0

        ComboBox1.DisplayMember = "Region"
        ComboBox1.ValueMember = "id"
        ComboBox1.DataSource = dt

Thanks very much, problem solved...lesson learned

Great... Happy i could help you. Some times small things wont strike in mind :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.