473,587 Members | 2,316 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Moving item from 1 listbox to another listbox

Hi guys,

I got 2 listboxes in a window form, one on left and one on right. The
1st listbox have some items while the 2nd listbox is empty. Also there
are 2 buttons between the 2 listboxes which used to move item from/to
the 1st and 2nd listbox

My problem here is that after I bind the data to the 1st listbox (from
a dataTable, using DisplayMember and ValueMember), and I try to move 1
of the item from this 1st listbox to the 2nd listbox by:

If ListBox1.Select edIndex <-1 Then
ListBox2.Items. Add(ListBox1.Se lectedItem)
ListBox1.Items. Remove(ListBox1 .SelectedItem)
End If

Item can be add to the 2nd listbox but the displayText of it becoming:

System.Data.Dat aRowView
Anyone can help? Thanks!! :)

Mar 20 '07 #1
3 5759
Perry,

The listbox has two methods to show items, one by using his own collection,
second by showing it from the underlying bounded collection.

They can not mix up while the second method has priority. Do you want to
achieve what you want, than you have or all the items first to set in the
listbox items and not bind or you have to move the rows in your datatables.

If it is about one datatable, than you can just add a column which tells in
what listbox it has to be.

Cor

<pe************ @gmail.comschre ef in bericht
news:11******** **************@ l77g2000hsb.goo glegroups.com.. .
Hi guys,

I got 2 listboxes in a window form, one on left and one on right. The
1st listbox have some items while the 2nd listbox is empty. Also there
are 2 buttons between the 2 listboxes which used to move item from/to
the 1st and 2nd listbox

My problem here is that after I bind the data to the 1st listbox (from
a dataTable, using DisplayMember and ValueMember), and I try to move 1
of the item from this 1st listbox to the 2nd listbox by:

If ListBox1.Select edIndex <-1 Then
ListBox2.Items. Add(ListBox1.Se lectedItem)
ListBox1.Items. Remove(ListBox1 .SelectedItem)
End If

Item can be add to the 2nd listbox but the displayText of it becoming:

System.Data.Dat aRowView
Anyone can help? Thanks!! :)

Mar 20 '07 #2
Thanks for your reply Cor :)

Yea, I just got one datatable, Would you please tell me the way to
bind the data from a dataTable (which got 2 column: ID and Name. In
this case, the displaymember will be Name for Listbox1, Value will be
ID) ?

Many Thanks
On Mar 20, 4:46 pm, "Cor Ligthert [MVP]" <notmyfirstn... @planet.nl>
wrote:
Perry,

The listbox has two methods to show items, one by using his own collection,
second by showing it from the underlying bounded collection.

They can not mix up while the second method has priority. Do you want to
achieve what you want, than you have or all the items first to set in the
listbox items and not bind or you have to move the rows in your datatables.

If it is about one datatable, than you can just add a column which tells in
what listbox it has to be.

Cor

<perrycheung... @gmail.comschre ef in berichtnews:11* *************** ******@l77g2000 hsb.googlegroup s.com...
Hi guys,
I got 2 listboxes in a window form, one on left and one on right. The
1st listbox have some items while the 2nd listbox is empty. Also there
are 2 buttons between the 2 listboxes which used to move item from/to
the 1st and 2nd listbox
My problem here is that after I bind the data to the 1st listbox (from
a dataTable, using DisplayMember and ValueMember), and I try to move 1
of the item from this 1st listbox to the 2nd listbox by:
If ListBox1.Select edIndex <-1 Then
ListBox2.Items. Add(ListBox1.Se lectedItem)
ListBox1.Items. Remove(ListBox1 .SelectedItem)
End If
Item can be add to the 2nd listbox but the displayText of it becoming:
System.Data.Dat aRowView
Anyone can help? Thanks!! :)- Hide quoted text -

- Show quoted text -

Mar 20 '07 #3
Perry,

Written here so watch typos

dim myFilterColumn as dataColumn(filt er)
myDataTable.Col umns.Add("myFil terColumn")
dim myDataView as new DataView(myData Table)
dim myDataView2 as new DataView(myData Table)
myDataView1.Row Filter = "myFilterCo lumn = 1"
myDataView1.Row Filter = "myFilterCo lumn = 2"
myDataView1(3). "myFilterColumn " = "1"
etc.

myListBox1.data source = myDataView1
myListBox2.data source = myDataView1
In this situation only the second name will be displayed in listbox1
<pe************ @gmail.comschre ef in bericht
news:11******** **************@ n59g2000hsh.goo glegroups.com.. .
Thanks for your reply Cor :)

Yea, I just got one datatable, Would you please tell me the way to
bind the data from a dataTable (which got 2 column: ID and Name. In
this case, the displaymember will be Name for Listbox1, Value will be
ID) ?

Many Thanks
On Mar 20, 4:46 pm, "Cor Ligthert [MVP]" <notmyfirstn... @planet.nl>
wrote:
>Perry,

The listbox has two methods to show items, one by using his own
collection,
second by showing it from the underlying bounded collection.

They can not mix up while the second method has priority. Do you want to
achieve what you want, than you have or all the items first to set in the
listbox items and not bind or you have to move the rows in your
datatables.

If it is about one datatable, than you can just add a column which tells
in
what listbox it has to be.

Cor

<perrycheung.. .@gmail.comschr eef in
berichtnews:11 *************** *******@l77g200 0hsb.googlegrou ps.com...
Hi guys,
I got 2 listboxes in a window form, one on left and one on right. The
1st listbox have some items while the 2nd listbox is empty. Also there
are 2 buttons between the 2 listboxes which used to move item from/to
the 1st and 2nd listbox
My problem here is that after I bind the data to the 1st listbox (from
a dataTable, using DisplayMember and ValueMember), and I try to move 1
of the item from this 1st listbox to the 2nd listbox by:
If ListBox1.Select edIndex <-1 Then
ListBox2.Items. Add(ListBox1.Se lectedItem)
ListBox1.Items. Remove(ListBox1 .SelectedItem)
End If
Item can be add to the 2nd listbox but the displayText of it becoming:
System.Data.Dat aRowView
Anyone can help? Thanks!! :)- Hide quoted text -

- Show quoted text -


Mar 20 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2968
by: Angela | last post by:
I'm having trouble figuring out how to move a list from one listbox to another using a command button. The idea is to click on a command button and all items in listbox A will move over to listbox B. I'm able to move one item using AddItem, but I don't know how to move the whole list. Thank you.
2
5115
by: Zhang Le | last post by:
Hello, Is there a quick way to replace the content of a single item in tkinter's listbox? Currently my solution is to first delete the item, then insert a new item at the same position. I think there may be better way. Zhang Le
2
1541
by: Kevin Quigley | last post by:
Hi, I have an application that allows users to select items from one listbox and in doing so the item is removed from the original list and displayed in the other. I had this working in the code behind page but each selection resulted in a postback. I have now tried to implement this using javascipt and the transferring of items works...
3
3601
by: Paul T. Rong | last post by:
I have a listbox (of product names) control on my form. I want to pass the selected item (a product name) to a subform, and the product unitprice should apear automatically next to the product name in the subform. Is it possible? How do I do this? Thanks in advance. Paul from Slovakia
7
2505
by: Grant Schenck | last post by:
Hello, I have a ListBox control on a form. I add members of a class to the Items collection. They show up and I can select them. The text shown is from my classes ToString override. Now, later on I need to update this item. I find it in the Items collection and update a member used by the ToString member function. However, the text...
5
11439
by: Kay | last post by:
Hello, I have two list boxes on my form, one initially displays with items and the other displays blank, by clicking a button, it is possible to move items from one box to another and vice a versa, this works fine. I also have a dropdown list on the page with autopost back = true, my problem is as follows: when the user selects an option in...
3
7376
by: Dany P. Wu | last post by:
Hi everyone, One of my Windows forms contain two listbox controls, with Add and Remove buttons between them. The idea is to allow users to select multiple items from one ListBox, click the Add button, and the selected items will move to the second ListBox. I've been trying to use the ListBox.SelectedObjectCollection with no success. It...
4
6125
by: rn5a | last post by:
I am binding a DropDownList with records existing in a database table. I want to add an extra item *SELECT COMPANY* at index 0 so that by default, it gets selected. This is how I tried it but the extra item just doesn't get added to the DropDownList: ============================================= <script runat="server"> Sub...
1
1976
by: MayhemMickells | last post by:
Alright soo, I'm working on this program for my programming class using VB 2005 and it's driving me insane. See the program is like this. The main form has a list box for selected products and beside it is the total for all the products you selected. The other form is list box of all the products you can select it. You can choose what product...
0
7915
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7843
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8205
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7967
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3840
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2347
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.