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 / May 2006

Tip: Looking for answers? Try searching our database.

DisplayMember is being ignored

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dundealing - 24 May 2006 19:29 GMT
Hi,

I have the following code to set the DataSource of a ComboBox to a certain
table in an untyped DataSet, and I also want to set the DisplayMamaber of the
ComboBox to a certain column:

 cmbID.DataSource = Me.Ds.Tables("Groups")
 Dim str As String = Me.Ds.Tables("Groups").Columns("CustomerID").ColumnName
  Me.cmbCustomerID.DisplayMember = str

Problem is, I have stepped through this code, and str is assigned the value
"CustomerID".  I then step over the line where str is assigned as the
DisplayMember.  However, the value of DisplayMember remains at "".  The
ComboBox is populated with the appropriate number of items, but each simply
says "System.Data.DataRowView".

Any ideas?  The code was fine, no changes were made, it just suddenly
doesn't like it.  I then changed some code in another class, ran it, and the
ComboBox populated fine.  I Ran it again, broken again. Most baffling.
Dmytro Lapshyn [MVP] - 25 May 2006 12:18 GMT
Hi,

Try "Groups.CustomerID" as the DisplayMember name.

> Hi,
>
[quoted text clipped - 20 lines]
> the
> ComboBox populated fine.  I Ran it again, broken again. Most baffling.
Dundealing - 25 May 2006 15:09 GMT
As I said, it is an untyped DataSet, and therefore the CustomerID property
available with a Typed DataSet is not available here.

I managed to sort it out by setting the DisplayMember before setting the
DataSource. Don't know why it works but it did.

> Hi,
>
[quoted text clipped - 24 lines]
> > the
> > ComboBox populated fine.  I Ran it again, broken again. Most baffling.
Dmytro Lapshyn [MVP] - 25 May 2006 16:06 GMT
What's specified in DisplayMember is the data column name, not a property
name. Therefore, should work for untyped datasets as well.

> As I said, it is an untyped DataSet, and therefore the CustomerID property
> available with a Typed DataSet is not available here.
[quoted text clipped - 33 lines]
>> > the
>> > ComboBox populated fine.  I Ran it again, broken again. Most baffling.
Dundealing - 25 May 2006 18:44 GMT
I understand that the value needed for the DisplayMember is a column name,
but if the Dataset is untyped you need to access the table in a fashion  like
this:

Me.Ds.Tables("Groups")

whereas when you create a typed dataset, the tables, columns and rows become
properties of the DataSet and you can access them like this:

Me.ds.Groups

This syntax would not work with an untyped DataSet.

> What's specified in DisplayMember is the data column name, not a property
> name. Therefore, should work for untyped datasets as well.
[quoted text clipped - 36 lines]
> >> > the
> >> > ComboBox populated fine.  I Ran it again, broken again. Most baffling.

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.