D
Don
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
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