Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / June 2007

Tip: Looking for answers? Try searching our database.

Binding to a ComboBox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bill Gower - 27 Jun 2007 00:39 GMT
I have a combo box in which I want to display the distinct values in a field
in a table.

Depending on the table name and the field name entered by the user, I build
an sql statement

_Sql = "Select distinct " + _fieldName + " from " + _tableName

and fill a dataset with the results

How do I bind this to a combobox?

cbFieldValues.DataSource = ds.Table[0].DataSet;
cbFieldValues.DisplayMember = ?;
cbFieldValues.DisplayValue = ?;

Thanks
Bill
Mr. Arnold - 27 Jun 2007 01:43 GMT
>I have a combo box in which I want to display the distinct values in a
>field in a table.
[quoted text clipped - 10 lines]
> cbFieldValues.DataSource = ds.Table[0].DataSet;
> cbFieldValues.DisplayMember = ?;     cbFieldValues.DisplayValue = ?;

DisplayMember is a text represntaion of the data in the dropdown list. It
could be the text data for the field name from the ds.table.

Displayvalue is the value from a ds.table for the value to be selected when
a section is made from the combox.

*Bill*   will be displayed as a combox selection if the field from the
da.table was "Name"

Displayvalue, which is a hidden field, which will point to a da.table called
NameNO. If NameNO = 1, then it will be linked to Bill in the combox.

Bill -- its value = 1.
Gower -- its value = 2.

You select Bill out of the dropdown list, the value of 1 is going to be
return and 2 if Gower is selected.

It could be this too DisplayMember = da.Table (Name) and DisplayValue =
da.Table(Name)

Bill in the dropdown box for selection and the value returned is *Bill*
returned when *Bill* is selected.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.