Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Control to display multi-column selection

Posted on 2004-09-14
7
Medium Priority
?
516 Views
Last Modified: 2008-01-09
I need to perform a lookup on a SQL 2000 database, and utilize the results in a control for user selection.  The data will be used as a validation control to ensure the only Employees that reside in our Employee database will have accounts created on the network. I understand enough to get me as far as the code below, but need additional help.

        'Generate SQL connection with string
        Dim CPcon As SqlConnection = New SqlConnection("MYDATASOURCE")
        'Create SQL command with select statement
        Dim cmd As SqlCommand = New SqlCommand("SELECT EMPL_ID,FIRST_NAME,LAST_NAME FROM EMPL", CPcon)
        'Set timeout to 30 seconds on connection
        cmd.CommandTimeout = 30
        'Create a DataAdapter
        Dim DA As SqlDataAdapter = New SqlDataAdapter
        'Set command for Data Adapter to execute
        DA.SelectCommand = cmd
        'Exception Handling
        Try
            'Open Connection
            CPcon.Open()
            'Create Dataset
            Dim ds As DataSet = New DataSet
            'Fill Dataset from Data Adapter from the Employee Table
            DA.Fill(ds, "EMPL")
            'Set datasource of combobox to Employee table in Dataset
            ComboBox1.DataSource = ds.Tables("EMPL")
            'Set the display member of Combo box
            ComboBox1.DisplayMember = "LAST_NAME"
            ComboBox1.ValueMember = "EMPL_ID"
        Catch ex As Exception
            MessageBox.Show(ex.ToString)
        Finally
            'Close connection
            CPcon.Close()
        End Try

This code works fine at returning a single value as the datasource of the combobox, but I really need to have the employee ID, First Name, and Last Name all in the selection and return only the Employee ID when SelectedIndexChanged event fires.  I have seen a few places where the drop down was changed to show a datagrid selection, but I am not technically adept enough to understand how to implement that.  I have also heard and utilized owener drawn controls, but the down side is the way that the data lines up.  If there is another control that would be better sutied to displaying a list of this data in a selectable format, I am willing to use it instead.
0
Comment
Question by:john_vernon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
7 Comments
 
LVL 14

Expert Comment

by:ptakja
ID: 12060756
You could use a grid or a multi-column list box.

I  don't think the standard Combobox supports multiple columns.  If I remember, you would need to go with a third-party control, such as the UltraComboBox from Infragistics (http://www.infragistics.com).  The UltraComboBox control basically combines a grid with a combobox.  So you can have a combo with multiple columns, and have it return a value to your code from a visible column, or a hidden one.  It is part of the NetAdvantage suite.  Base price will run you about $500.
0
 

Author Comment

by:john_vernon
ID: 12063663
For such a simple program, I would not be willing to make that type of investment.  Is there an open source alternative?
0
 

Author Comment

by:john_vernon
ID: 12067803
Do you have code examples for the multi-column listbox? That would problably do the trick!
0
 

Author Comment

by:john_vernon
ID: 12073957
I have temporarily solved my own problem by creating an additional field in the database to hold the content of my combo/listbox.  It was not the approach I was looking for but it gets me to my next step.  I would still be willing to give the points to anyone with a good code example.  I have read several other posts pertaining to other control sets with the ability to add multiple columns, but for these controls it did not appear that you could set a datasource.  Instead, you would have to add items in one at a time.
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 12327294
PAQed, with points refunded (125)

Computer101
E-E Admin
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question