Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Removing Item from list Box


Reply
 
Thread Tools Display Modes
  #1  
Old 02-26-2002, 03:04 AM
geo100100 geo100100 is offline
Regular
 
Join Date: Feb 2002
Location: Manchester
Posts: 52
Question Removing Item from list Box


I have a list box which contains several records, I want to be able to highlight one of the records in the list box and click on a command button to remove it.

Does anyone know the code to go behind the button??? I know you need .RemoveItem cuase ive tried that and ive got it to delete a record in a certain index position however I need to delete the one selected.

Thanks.
Reply With Quote
  #2  
Old 02-26-2002, 03:17 AM
Flyguy's Avatar
Flyguy Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 18,882
Default

The selected item in a listbox is the one returned from the .Listindex property.
Reply With Quote
  #3  
Old 02-26-2002, 03:20 AM
gallicus gallicus is offline
Junior Contributor
 
Join Date: Dec 2001
Location: at work... probably :-(
Posts: 366
Default

SelectedItem and HitTest will decide which list item you have clicked on.


Me.ListView1.SelectedItem = Me.ListView.HitTest(X, Y)
__________________
(A)bort, (R)etry, (G)et a beer?
Reply With Quote
  #4  
Old 02-26-2002, 03:23 AM
geo100100 geo100100 is offline
Regular
 
Join Date: Feb 2002
Location: Manchester
Posts: 52
Default

thanks for the replys but ive just tried that code and it didnt work it says method or data item not found.

I thought the code would be:

List1.ListIndex.RemoveItem List1.Text but that doesnt work either anyone got any ideas?
Reply With Quote
  #5  
Old 02-26-2002, 03:24 AM
Flyguy's Avatar
Flyguy Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 18,882
Default

Code:
List1.RemoveItem List1.ListIndex
Reply With Quote
  #6  
Old 02-26-2002, 03:27 AM
geo100100 geo100100 is offline
Regular
 
Join Date: Feb 2002
Location: Manchester
Posts: 52
Default thanks

thank you works perfectly now
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->