Combobox help

sinog2006

New member
Joined
Nov 9, 2009
Messages
2
Programming Experience
3-5
I have the database columns ia a table as follows: I need to get this into vb.net combobox(dropdown). How to get a tab after the first column?? I tried Name & vbTab & Code...But it doesn't help. Please help as soon as possible. I am using visual studio 2003.

Also please let me know how to get back just the first column.(I just have to insert the 1st column) on form submission.
 
You didn't say what kind of database you are using. Here is an example for MS Access. Does this work for you?
VB.NET:
Imports System.Data.OleDb

Public Class Form1

    Private connstring As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\db1.mdb;"
    Private conn As OleDb.OleDbConnection

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Using conn As New OleDb.OleDbConnection(connstring)
              conn.Open()

        Me.ComboBox1.ValueMember = "COLUMN_NAME"
        Me.ComboBox1.DataSource = conn.GetSchema("Columns", _
                                                       New String() {Nothing, _
                                                                     Nothing, _
                                                                     "CodeItems"})
        End Using  'close and dispose
    End Sub

End Class
 
Let me make it simple:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim string1 As String = "test"

Dim string2 As String = "location"

Me.ComboBox1.Items.Add(string1 + vbTab + string2)

End Sub

I need to insert a tab after string1, vbTab doesn't do anything. Please help.
 
Combo boxes and ListBoxs are meant to hold single items, not multiple items along the same line, which, actually, will be considered by the control as a single item.

It sounds to me like you would be better suited using a control designed for multiple items/columns like a ListView.
 

Latest posts

Back
Top