473,804 Members | 2,246 Online
Bytes | Software Development & Data Engineering Community
+ 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 5791
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.finds tringexact(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(Com bobox2.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
28719
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 ItemsList) {
3
334
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 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
2
1948
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; listViewNextStateSelected.Items.Remove(oldItem); My problem occurs in the following scenario (example): Initially ListView empty
1
1738
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 member.
2
4887
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 2</asp:ListItem> <asp:ListItem Value="3">Item 3</asp:ListItem> <asp:ListItem Value="4">Item 4</asp:ListItem> <asp:ListItem Value="5">Item 5</asp:ListItem>
17
2725
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 pattern1 print >>orcfilename, line I am pretty sure my code isn't close to what I want. I need to be able
0
1375
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 gridview on the same page and removed from the ddl so that they can only be added once. What I want to do and can't seem to make work is the code that removes the ddl items that are already on the gridview at page load.
0
1411
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 items in the list(second combobox) which is not relavant to the item selected in first combobox. Can i have the code details on doding this in bc++(preferably)/vc++ ? Thanks
0
7735
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 Technology: Used in ASP.net Level: Beginner Introduction This code will help for the begineers, who want to learn, how to move the the items from one list box to another listbox with up and down facility.
0
9714
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9594
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10600
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10350
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6866
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4311
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
2
3834
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3002
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.