Hi,
if anyone can help me with this i would apreciate it.

I have 2 drop down lists, and between them, they have some values that
are similar. How can i fill the second drop down and remove the item
thats selected in the first drop down, so that the same item doesnt
appear on both drop downs?

i have tried doing this after i load both dropdowns:
2ndlist.Items.Remove(1stlist.SelectedItem.Text) BUT NOTHING HAPPENS. I
still get the value on both drop downs

it only works with the index:
2ndlist.Items.RemoveAT(1stlist.SelectedIndex) BUT its not right since
drop downs dont have the same amount of items.

Re: remove an item from a drop down list by Jeff

Jeff
Mon May 24 10:21:14 CDT 2004

On 24 May 2004 07:10:47 -0700, eliassidesmarina@rocketmail.com
(Marina) wrote:

>Hi,
>if anyone can help me with this i would apreciate it.
>
>I have 2 drop down lists, and between them, they have some values that
>are similar. How can i fill the second drop down and remove the item
>thats selected in the first drop down, so that the same item doesnt
>appear on both drop downs?
>
>i have tried doing this after i load both dropdowns:
>2ndlist.Items.Remove(1stlist.SelectedItem.Text) BUT NOTHING HAPPENS. I
>still get the value on both drop downs
>
>it only works with the index:
>2ndlist.Items.RemoveAT(1stlist.SelectedIndex) BUT its not right since
>drop downs dont have the same amount of items.

Marina

I think you will need to use the index, one of my apps does:

int intIndex = lstTasks.SelectedIndex;
if(intIndex > 0)
{
string strItem = lstTasks.Text;
lstTasks.Items.RemoveAt(intIndex);
lstTasks.Items.Insert(intIndex - 1, strItem);
lstTasks.SelectedIndex = intIndex - 1;
JWriteRunOrder();
}

This is for moving items in a ListBox but can be adapted to do
what you need.

--
Jeff Gaines - Damerham Hampshire UK


RE: remove an item from a drop down list by anonymous

anonymous
Tue May 25 01:46:02 CDT 2004

Dim i As Integer = cmb1.SelectedInde
Dim s As String = System.Convert.ToString(cmb1.Items.Item(i)

For i = 0 To cmb2.Items.Count -
Dim sTmp As Strin
sTmp = System.Convert.ToString(cmb2.Items.Item(i)
If s = sTmp The
cmb2.Items.RemoveAt(i
Exit Fo
End I
Nex


Re: remove an item from a drop down list by eliassidesmarina

eliassidesmarina
Tue May 25 06:13:29 CDT 2004

Jeff Gaines <jeff@nospam.co.uk> wrote in message news:<lj44b05b1j5lpjne1puriumlh9sbken8ou@4ax.com>...
> On 24 May 2004 07:10:47 -0700, eliassidesmarina@rocketmail.com
> (Marina) wrote:
>
> >Hi,
> >if anyone can help me with this i would apreciate it.
> >
> >I have 2 drop down lists, and between them, they have some values that
> >are similar. How can i fill the second drop down and remove the item
> >thats selected in the first drop down, so that the same item doesnt
> >appear on both drop downs?
> >
> >i have tried doing this after i load both dropdowns:
> >2ndlist.Items.Remove(1stlist.SelectedItem.Text) BUT NOTHING HAPPENS. I
> >still get the value on both drop downs
> >
> >it only works with the index:
> >2ndlist.Items.RemoveAT(1stlist.SelectedIndex) BUT its not right since
> >drop downs dont have the same amount of items.
>
> Marina
>
> I think you will need to use the index, one of my apps does:
>
> int intIndex = lstTasks.SelectedIndex;
> if(intIndex > 0)
> {
> string strItem = lstTasks.Text;
> lstTasks.Items.RemoveAt(intIndex);
> lstTasks.Items.Insert(intIndex - 1, strItem);
> lstTasks.SelectedIndex = intIndex - 1;
> JWriteRunOrder();
> }
>
> This is for moving items in a ListBox but can be adapted to do
> what you need.


The thing is that the drop downs are allready loaded with values and i
just need to remove from the 2nd drop down the value thats selected in
the 1st drop down. BUT since they dont have all the same values or
number of values the indexes on each value are different in each drop
down

Re: remove an item from a drop down list by eliassidesmarina

eliassidesmarina
Wed May 26 01:52:25 CDT 2004

> The thing is that the drop downs are allready loaded with values and i
> just need to remove from the 2nd drop down the value thats selected in
> the 1st drop down. BUT since they dont have all the same values or
> number of values the indexes on each value are different in each drop
> down

Ok, Nevermind. Found the answer:
2ndlist.Items.Remove(1stlist.SelectedItem)

as simple as that. BUT (theres always a but) i need an IF statement to
make sure i dont get an exeption in case the selected item in the 1st
list doesnt exist also in the second list and can't be removed!