Results 1 to 3 of 3

Thread: How to create multi-column combo box in vb.net?

  1. #1
    Join Date
    Feb 2009
    Posts
    5

    How to create multi-column combo box in vb.net?

    Hi,

    How to create multi-column combo box in vb.net?

    This combo box should have 2 or more columns like that!

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: How to create multi-column combo box in vb.net?

    This is a simple example of how to display table values (i.e. multiple columns) in a combo box. For the dropdown window, a form with a ListView docked to fill can be used. The MultiColumnCombobox class is inherited from the System.Windows.Forms.Combobox class.

    Code:
    protected override void OnDropDown(System.EventArgs e){
        Form parent = this.FindForm();
        if(this.dataTable != null || this.dataRows!= null){
            MultiColumnComboPopup popup = new 
                                MultiColumnComboPopup(this.dataTable,
                                ref this.selectedRow,columnsToDisplay);
            popup.AfterRowSelectEvent+=
                                new AfterRowSelectEventHandler
                                (MultiColumnComboBox_AfterSelectEvent);
            popup.Location = new Point(parent.Left + 
                                this.Left + 4 ,parent.Top + 
                                this.Bottom + this.Height);
            popup.Show();
    The OnDropDown event of the ComboBox is overridden to display our popup from. The popup form should never be a modal, because the popup has to close, if the user decides to click elsewhere other than the grid on the dropdown form. To check where the user has selected something, I use the popup.AfterRowSelectEvent, to fire an event on the MulticolumnComboBox. To use the MulticolumnComboBox do the following:

    Code:
    multiColumnComboBox1.Table = dtable;//DataTable
    
    //Column to display after selection
    
    multiColumnComboBox1.DisplayMember = "Band";
    multiColumnComboBox1.ColumnsToDisplay = new 
        string[]{"Band","Song","Album"};//columns to display
    
    //in the dropdown grid
    http://www.codeproject.com/KB/combob...lumncombo.aspx

    I hope this helps you!

  3. #3
    Join Date
    Apr 2008
    Posts
    2,005

    Re: How to create multi-column combo box in vb.net?

    If U have ur field names as follows:
    Firsname Lasname ,ID
    U need to know that, There 're two types of combo box
    1. A combo box -Normal
    2. a data combo


    Thee First one, u will have it as
    yo will have to decare a recordset to select Firstname, lastname and a id from the table that house those records:

    eg
    dim rst as new adodb.recordset
    dim conn as new adodb.connection
    conn.open("dsn=datasourcename")
    set rst = conn.execute ("select Firstname, lastname ,Id from tablename ")

    do until rst.eof
    combo1.Additem rst!firstname +' '+ rst!Lastname +' ' rst!ID
    rst.movenext
    loop


    The second one uses Ado data control

    Where u will have the Ado datacontrol selecting as thus:
    select firstname +' '+ rst!Lastname +' ' rst!ID from tablename

    i hope u will get it

Similar Threads

  1. Create button to navigate to next blank cell in a column
    By Brad B in forum MS Office Support
    Replies: 1
    Last Post: 21-02-2012, 12:10 AM
  2. Replies: 4
    Last Post: 28-01-2012, 03:45 PM
  3. How to print content of a Multi column Listbox?
    By Bryant in forum Software Development
    Replies: 6
    Last Post: 27-07-2011, 11:48 AM
  4. Combo box multi selection
    By SoftWore in forum Software Development
    Replies: 2
    Last Post: 12-11-2009, 02:15 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,018,357.61560 seconds with 16 queries