My user control has a combobox with an arraylist attached to it along with custom add and remove methods.
The "Add" method is working great. However I don't understand why the "Remove" method isn't working. It neither removes the item from the arraylist nor from the combobox like it's supposed to do.
A couple of notes: cbx is the name of the combobox within my usercontrol, file is the name of the arraylist within my usercontrol. To try and debug this issue, I added a public variable elsewhere in my usercontrol. This variable is named "test". When I "watch" this test variable as the remove method operates, it DOES get set to 0 which IS the element that needs to be removed. File.count AND cbx.count both equal 3.
Thanks for any assistance you may be able to provide.
--
Don
'This is the call to the add method that DOES work.
cbxMyComboBox.add("New Item")
'This is the add method that DOES work
Public Overridable Sub add(ByVal n As String)
'add item to the combobox
cbx.Items.Add(n)
File.Add(n)
noLocations = false
'select the new item in the combobox
If Not cbx.Items.Count = 0 Then
cbx.SelectedIndex = cbx.Items.Count - 1
End If
end sub
'This is the call the remove method that DOESN'T work
cbxMyControl.Remove(cbxMyControl.selectedindex)
'This is the Remove method that DOESN'T work.
Public Overridable Sub remove(ByVal i As Integer)
cbx.Items.Remove(i)
File.Remove(i)
Test = i
If Not cbx.Items.Count = 0 Then
cbx.SelectedIndex = 0
noLocations = False
Else
noLocations = True
End If
end sub 3 3786
Hi Don,
Did you know that you did use remove with the syntax from removeat?
Cor
* "Don" <No****@nothanks.com> scripsit: The "Add" method is working great.* However I don't understand why the "Remove" method isn't working.* It neither removes the item from the arraylist nor from the combobox like it's supposed to do.
A couple of notes:* cbx is the name of the combobox within my usercontrol, file is the name of the arraylist within my usercontrol.* To try and debug this issue, I added a public variable elsewhere in my usercontrol.* This variable is named "test".* When I "watch" this test variable as the remove method operates, it DOES get set to 0 which IS the element that needs to be removed.* File.count AND cbx.count both*equal 3.
You will have to pass a reference to the object you want to be removed
to the 'Remove' method, the index can be passed to the 'RemoveAt'
method, not to 'Remove'.
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Hello Don,
the Remove method expects you to pass in the object to be removed. For your
example below, that would be the string "New Item", not the index of the
element to remove. If you want to remove an item at a specific index, you
can use the RemoveAt method instead.
HTH
Antoine
Microsoft Visual Basic .NET
--
This posting is provided "AS IS" with no warranties, and confers no rights.
-------------------- From: "Don" <No****@nothanks.com> Subject: Remove element from array list and combobox...... Date: Sun, 14 Dec 2003 11:16:41 -0500 Lines: 183 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00B3_01C3C233.BFCD9DB0" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Message-ID: <Oi**************@TK2MSFTNGP09.phx.gbl> Newsgroups: microsoft.public.dotnet.languages.vb NNTP-Posting-Host: pcp05997552pcs.benslm01.pa.comcast.net 68.81.60.128 Path:
cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTN GP08.phx.gbl!TK2MSFTNGP09.
phx.gblXref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.languages.vb:163977 X-Tomcat-NG: microsoft.public.dotnet.languages.vb
My user control has a combobox with an arraylist attached to it along with
custom add and remove methods.The "Add" method is working great. However I don't understand why the
"Remove" method isn't working. It neither removes the item from the
arraylist nor from the combobox like it's supposed to do.A couple of notes: cbx is the name of the combobox within my usercontrol,
file is the name of the arraylist within my usercontrol. To try and debug
this issue, I added a public variable elsewhere in my usercontrol. This
variable is named "test". When I "watch" this test variable as the remove
method operates, it DOES get set to 0 which IS the element that needs to be
removed. File.count AND cbx.count both equal 3.Thanks for any assistance you may be able to provide. -- Don 'This is the call to the add method that DOES work. cbxMyComboBox.add("New Item") 'This is the add method that DOES work Public Overridable Sub add(ByVal n As String) 'add item to the combobox cbx.Items.Add(n) File.Add(n) noLocations = false 'select the new item in the combobox If Not cbx.Items.Count = 0 Then cbx.SelectedIndex = cbx.Items.Count - 1 End If end sub 'This is the call the remove method that DOESN'T work cbxMyControl.Remove(cbxMyControl.selectedindex) 'This is the Remove method that DOESN'T work. Public Overridable Sub remove(ByVal i As Integer) cbx.Items.Remove(i) File.Remove(i) Test = i If Not cbx.Items.Count = 0 Then cbx.SelectedIndex = 0 noLocations = False Else noLocations = True End If end sub This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: koperenkogel |
last post by:
Dear cpp-ians,
I am working with a vector of structures.
vector <meta_segment> meta_segm (2421500);
and the structure look like:
struct meta_segment
{
float id;
float num;
|
by: vimal patel via DotNetMonster.com |
last post by:
hi,
i want to remove array element from list.
Suppose 5,6,7,8,9 is a array assigned.
i want to remove element 7 from the array.
How can i remove this?
Please help me
Thanks
--
|
by: eksamor |
last post by:
I have a simple linked list:
struct element {
struct element *next;
int start;
};
struct list {
struct element *head;
|
by: oLgAa25 |
last post by:
Hello all,
I am back
I have this question
everything compiles fine, but I just need to check for an index that is
more than the array size. Although it says out of bound, but it is
still...
|
by: brasilino |
last post by:
Hi Folks:
I've been looking (aka googling) around with no success.
I need a usability beyond 'pop()' method when removing an Array
elements. For example:
oName = new...
|
by: Richard Maher |
last post by:
Hi,
I have read many of the copius entries on the subject of IE performance (or
the lack thereof) when populating Select Lists.
I don't mind the insert performance so much, (I get 100x120byte...
|
by: SM |
last post by:
Hello
I'm trying to create a multi dimensional array in JavaScript, but
after some reading i still can't figure out how to apply it to my
model.
Here it is:
I have a list A and for each item...
|
by: Zytan |
last post by:
Obviously you can't just use a simple for loop, since you may skip
over elements.
You could modify the loop counter each time an element is deleted.
But, the loop ending condition must be...
|
by: Barkingmadscot |
last post by:
I am stuck, i can workout how to remove lines from an array
I have loading a text file (a Log), I know which lines a need, but
the logs can be upto 30K sometimes bigger. I found trying to...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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,...
|
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...
|
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...
|
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...
| |