Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have two listboxes side by side. The listbox on the left is bound to a table, and shows Sql selected data from that table. I need to Add selected items from this listbox to the listbox on the right which is not bound to anything. The Listbox on the left has the following properties:

 

DisplayMember= Text field giving a display name from the table

ValueMember=UniqueID for item in the table

 

When I use the following:

 

RightSideListBox.Items.Add(LeftSideListBox.SelectedValue)

 

all I get is the Valuemember appearing in the right hand listbox. What I need is the DisplayMember showing in the right hand listbox, and some way of also recording the Valuemember, so I can retrieve data from the same table later, based on the UniqueID it returns for the originating table.

 

I tried using :

 

RightSideListBox.Items.Add(LeftSideListBox.SelectedItem)

 

but while that appears to add the datarow object to the right hand listbox, it displays 'System.Data.DataRowView' in the listbox control. Again, what I need is to see the same DisplayMember for the selected item in the left side listbox displayed in the right side listbox, and have some way of retrieving the ValueMember for later use.

 

Any help is greatfully appreciated!

 

Regards,

 

James

  • Moderators
Posted

you can use the Dataset Tables to get the selected item...

ds.Tables(0).Rows(LeftSideListBox.SelectedIndex).Item(1)
'Tables(0)... is the first table (you can use the name instead
'Item(0)... is the ColumnIndex, you probably have 2 columns in this case.

Visit...Bassic Software

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...