OK, I figured it out. The "Remove" method apparently wants the value to be
removed and not the index which contains the value to be removed. I would
apparently is not the case.
So I found my error.
Thanks for everyone's assistance.
> I do have a data table which provides the information that I am using to
> build my objects, but then after that, there is no relationship between my
> data tables and the list box. If I had bound my datatable to the list box
> control, then, as you have suggested, the problem would be in deleting the
> row from the datatable and then that supposidly would have made the list
box
> correct.....but this is not the situation!
> Still lost to explain why the row still remains....
> > I wouldn't swear that this is your solution, but are you using an
> underlying
> > datatable as the source for the listbox, you'd have to delete the record
> > from the underlying datatable and perform and update before the item
would
> > be omitted. I may be reading this too simplistically tho...
> > --- Jim ---
> > > I am adding the entries to the listbox via code and I am removing them
> by
> > > code. The code to add the entries is as follows (pulling the entries
> > from
> > > the DataSet - building my object - and then adding the object to the
> > > Listbox:
> > > Do Until i = DsStockData2.Tables("Company").Rows.Count()
> > > Dim obj As StockData
> > > Dim exch As Integer
> > > If DsStockData2.Tables("Company").Rows(i).Item("Exchange") Is
> > > DBNull.Value Then
> > > exch = 0
> > > Else
> > > exch = DsStockData2.Tables("Company").Rows(i).Item("Exchange")
> > > End If
> > > obj = New
> > > StockData(DsStockData2.Tables("Company").Rows(i).Item("Comp_ID"), _
> DsStockData2.Tables("Company").Rows(i).Item("Name"),
> > _
> > DsStockData2.Tables("Company").Rows(i).Item("Symbol"),
> > > _
> > > exch, _
> > > DsStockData2.Tables("Company").Rows(i).Item("TotalHeld"))
> > > lstCompanyNames.Items.Add(obj)
> > > i += 1
> > > Loop
> > > Here is the code to remove the item from the listbox....
> > > MsgBox("Total items before the delete of item in listbox = " &
> > > lstCompanyNames.Items.Count)
> > > lstCompanyNames.Items.Remove(lstCompanyNames.SelectedIndex)
> > > MsgBox("Total items now in the listbox = " &
> lstCompanyNames.Items.Count)
> > > The row count before the delete is 12 and the rowcount after the
delete
> is
> > > 12.
> > > > It sounds like you may be using the properties window to define the
> > > listbox
> > > > entries and then using code to remove an item. If that is the case,
> > when
> > > > you create a new instance of the form it will grab all the values
from
> > > your
> > > > design-time settings in the property grid. You will need to remove
> the
> > > > values from the property grid in design-mode.
> > > > Dave & Jim
> > > > VB .NET Development
> > > > --
> > > > This posting is provided "AS IS" with no warranties, and confers no
> > > rights.
> > > > > I created a number of objects and added those objects to a list
box.
> > > Now
> > > > > when I attempt to use the remove method, it seems to function, but
> > when
> > > > the
> > > > > form is displayed back, the item is not removed, What gives? Is
> > there
> > > > > something more that I need to do to get it out of the listbox?
> > > > > Your assistance is greatly appreciated!