473,473 Members | 1,489 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 5760
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: 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
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,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.