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.a dd("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.SelectedInd ex = cbx.Items.Count - 1
End If
end sub
'This is the call the remove method that DOESN'T work
cbxMyControl.Re move(cbxMyContr ol.selectedinde x)
'This is the Remove method that DOESN'T work.
Public Overridable Sub remove(ByVal i As Integer)
cbx.Items.Remov e(i)
File.Remove(i)
Test = i
If Not cbx.Items.Count = 0 Then
cbx.SelectedInd ex = 0
noLocations = False
Else
noLocations = True
End If
end sub 3 3809
Hi Don,
Did you know that you did use remove with the syntax from removeat?
Cor
* "Don" <No****@nothank s.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****@nothank s.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.B FCD9DB0" 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.publi c.dotnet.langua ges.vb NNTP-Posting-Host: pcp05997552pcs. benslm01.pa.com cast.net 68.81.60.128 Path:
cpmsftngxa07.ph x.gbl!cpmsftngx a06.phx.gbl!TK2 MSFTNGP08.phx.g bl!TK2MSFTNGP09 .
phx.gblXref: cpmsftngxa07.ph x.gbl microsoft.publi c.dotnet.langua ges.vb:163977 X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.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.SelectedInd ex = cbx.Items.Count - 1 End If end sub 'This is the call the remove method that DOESN'T work cbxMyControl.R emove(cbxMyCont rol.selectedind ex) 'This is the Remove method that DOESN'T work. Public Overridable Sub remove(ByVal i As Integer) cbx.Items.Remov e(i) File.Remove(i) Test = i If Not cbx.Items.Count = 0 Then cbx.SelectedInd ex = 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 deleting the last element. Can someone help please
Thank you all
Olga
I just wanted to test my function,so don't bother with main, and print
|
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 Array('Lucas','Brasilino','Silva');
oName.remove('Brasilino');
oName.toString(); // puts out 'Lucas,Silva'
| |
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 rows
inserted/sec up to 500, and 100rows/6secs up to 3000, which isn't great but
then the Row Count is clicking away for the user to see and they can hit the
"cancel" button at anytime, so overall I'm happy), what really disappoints
me is the...
|
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 in the list A i want to associate an
undetermined number of items. The complication for me is the fact that
the items to associate in list A are undetermined.
|
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 checked on each iteration,
since the Count changes as you delete elements. I would think it is
guaranteed to be computed each time, and not cached.
So, is this the best way?
|
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 delete
the lines from the log file before loading in the array took ages, i
thought i would be alot quicker to put in an array and remove the
unwanted lines.
Dim text As Array
Dim lines As New List(Of String)
|
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,...
|
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...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |