Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 26-02-2009
Member
 
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!
Reply With Quote
  #2  
Old 26-02-2009
Member
 
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!
Reply With Quote
  #3  
Old 26-02-2009
Member
 
Join Date: Apr 2008
Posts: 2,001
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
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to create multi-column combo box in vb.net?"
Thread Thread Starter Forum Replies Last Post
Create button to navigate to next blank cell in a column Brad B MS Office Support 1 21-02-2012 12:10 AM
How to create a multi column drop down list in Microsoft Excel RYAN$ MS Office Support 4 28-01-2012 03:45 PM
How to print content of a Multi column Listbox? Bryant Software Development 6 27-07-2011 11:48 AM
Combo box multi selection SoftWore Software Development 2 12-11-2009 02:15 PM


All times are GMT +5.5. The time now is 10:04 PM.