You are not logged in.

JimMarsalis

Beginner

  • "JimMarsalis" is male
  • "JimMarsalis" started this thread

Posts: 1

Date of registration: Dec 24th 2008

Location: New Orleans

Occupation: high school math teacher

Hobbies: running, cryptic crosswords, math

  • Send private message

1

Friday, February 27th 2009, 9:29pm

Deleting and item in a listbox

I am trying to delete an item in a listbox after selecting the item. For some reason, this has always been a problem in VBA, and I was hoping that a simple .DeleteItem would be available in Jabaco. Any suggestions?

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

2

Friday, February 27th 2009, 10:36pm

Hi,
how about this?

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Public Sub Form_Load()
   List1.AddItem "now"
   List1.AddItem "is the time"
   List1.AddItem "for all good men ..."
End Sub

Public Sub Command1_Click()
   Dim lm As javax#swing#DefaultListModel 
   
   If List1.ListIndex >= 0 Then
      lm = Cast(List1.Parent.getModel(), javax#swing#DefaultListModel)
      lm.removeElementAt(List1.ListIndex)      
   End If
End Sub


ListBox should have a removeElementAt() method in the Jabaco framework.

Happy experimenting!

A1880

Rate this thread
WoltLab Burning Board