473,403 Members | 2,366 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Removing items from a combobox

Hello

I am trying to make the items in my combobox be removed if they are present in my array
I cant however get my code to work. The values are read into my combobox using a datareader. I then want to remove items from the items collection of the combobox if they are in my array. Here is what i try

If i > 0 The
For i= 0 To (MyArray.Count - 1
Combobox1.Items.Remove(MyArray
Next
End I

can someone tell me what the problem could be

thank you
Jul 21 '05 #1
3 5759
Cor
Hi Varun,

You have two tables, not one, where the index can be different.
I do not know what kind of array you have and therefore i take another
approach

I have typed it here, so watch errors or typos

\\\
dim i as integer
For i = 0 to MyArray.count -1
'We go through the array
dim y as integer = combobox1.findstringexact(trim(myarray(i)))
'If we find it y is the index of the combobox row else it is -1
if y<>-1 then
combobox1.items.removeAt(y)
end if
next
///
As said not tested just typed here.

You can try it?

Cor

Hello,

I am trying to make the items in my combobox be removed if they are present in my array. I cant however get my code to work. The values are read into my combobox using a datareader. I then want to remove items from the items collection of
the combobox if they are in my array. Here is what i try:
If i > 0 Then
For i= 0 To (MyArray.Count - 1)
Combobox1.Items.Remove(MyArray)
Next i
End If
can someone tell me what the problem could be?

thank you

Jul 21 '05 #2
Hello Cor

The order of the process is the user select item from combobox1. A datareader is run against the DB and used to fill combobox2. User now selsect item from combobox2 and then presses Button1. When button1 is clicked the item chosenin from combobox2 is added to my arraylist.

MyArray.Add(Combobox2.Text
'increment the arrayInde
i= (i+ 1

The whole process is then repeated so another item from combobox2 can be selected

What i want to ensure is that the same item that was selected (i.e those in my arraylist) does not reappear in combobox2

Jul 21 '05 #3
Hello Cor

Thank you for your help. My problem is now fix
Jul 21 '05 #4

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

Similar topics

3
by: Filippo P. | last post by:
Hi there, I have a menu (Collection) that needs to be trimmed based on security access of the logged user. protected void AdjustMenuBasedOnUserSecurity(Items ItemsList) { foreach (Item i in...
3
by: Varun | last post by:
Hello I am trying to make the items in my combobox be removed if they are present in my array I cant however get my code to work. The values are read into my combobox using a datareader. I then...
2
by: Curious | last post by:
Hi, I am removing problems but I am having a problem. The code below is the code being used to remove items from the listview. ListViewItem oldItem = listViewAllStates.SelectedItems;...
1
by: Sam | last post by:
Hello, Framework: 2.0 IDE: VBExpress Problem: I have a datagrid that contains a combobox type column. The grid is bound to a datatable. The comboboxes have a value member and a display...
2
by: Milsnips | last post by:
hi there, i have the following HTML code: -------------------------- <asp:DropDownList id="hddList" runat="server"> <asp:ListItem Value="1">Item 1</asp:ListItem> <asp:ListItem Value="2">Item...
17
by: Eric_Dexter | last post by:
def simplecsdtoorc(filename): file = open(filename,"r") alllines = file.read_until("</CsInstruments>") pattern1 = re.compile("</") orcfilename = filename + "orc" for line in alllines: if not...
0
by: mharness | last post by:
Hello, Under most circumstances I don't have any trouble removing items from a dropdownlist but this time it's not working. I have a ddl that list items which, when choosen are added to a...
0
by: Pramod Kadur | last post by:
I have a combobox which has a list of items displayed by default. Based on selection of an item in first combobox, i need to display the related items in my second combobox, so i need to remove those...
0
by: vivek kapile | last post by:
Title: Javascript for Adding & Removing Items from a one Listbox to another Author: Vivek Kapile Email: snipped Language: JavaScript Platform: Javascript in ASP.net...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.