Trouble modifying text after copying items between listboxes

A

AlBruAn

I have an application under development that contains, among other controls,
two listboxes containing Available Tasks and Assigned Tasks. Let's say one
of the Available Tasks is "Send Letter" and the user wishes to copy it over
to the Assigned Tasks listbox; in that case, it's a simple matter of
executing the following line of code:


lbAssignedTasks.Items.Add(lbAvailableTasks.Items(lbAvailableTasks.SelectedIndex()))

Let's further state that a few other tasks are assigned and then the user
wants to assign sending a follow-up letter by again selecting "Send Letter".
In this case, I want to modify the first instance of "Send Letter" to read
"Send Letter - 1" and modify the second instance of "Send Letter" to read
"Send Letter - 2". I've attempted to set the text for the added instance by
setting it as follows:

lbAssignedTasks.Items(lbAssignedTasks.Items.Count - 1).Text =
lbAssignedTasks.Items(lbAssignedTasks.Count - 1).Text + " - " + CType(2,
String)

and I've attempted to set the text for the first instance by setting it as
follows:

lbAssignedTasks.Items(i).Text = lbAssignedTasks.Items(i).Text + " - " +
CType(1, String)

The value for i in both statements is determined by stepping through the
list of Assigned Tasks working from the last item to the first until I find
an item that .Contains("Send Letter").

As far as I can tell, that part seems to be working correctly, but modifying
the text value for an item in the Assigned Tasks listbox is somehow being
"sent back" to the Available Tasks listbox and modifying the text for "Send
Letter" to also be "Send Letter - 2".

Why is this happening and is there a workaround solution to my problem?
 
A

AlBruAn

You're answer worked perfectly. The only other thing I had to do was grab
the SelectedValue of the Available Task that was selected and reset the Value
property of the newly-assigned task after assigning it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top