Updating items in a listbox

tpra21

Active member
Joined
Oct 21, 2006
Messages
26
Programming Experience
1-3
Is it possible to update items in a list box on a form (without using a datagrid or database field)?

I have two forms. One is the main form and stands in the background. The other will pop up in front of it and allows a user to add a daily reminder. Once done, the popup window is closed and the user returns to the main form, which has been showing the entire time. It has a listbox that has the reminders in it, so when I get done adding one and return to it, the new reminder doesn't appear.

I tried refreshing the main form, listbox, and updating the listbox using the listbox.update() comand, but no go.

Thanks, Adam
 
Hi Adam,Try this
VB.NET:
Dim index As Integer
Dim searchString As String
 
searchString = "Old"
index = ListBox1.FindString(searchString)
ListBox1.Items(index) = "New Value"
Cheers Inhua :)
 
Last edited by a moderator:
Hi Adam,

My previous code will fail if there is not a match item with searchString. The following code will do checking for it and pops up a message if no matching searchString found.

VB.NET:
Dim index As Integer
Dim searchString As String
 
searchString = "Old"
index = ListBox1.FindString(searchString)
If index <> -1 Then
ListBox1.Items(index) = "New"
Else
MsgBox("No match item.")
End If
 
Last edited by a moderator:
Nice code, but that isn't what I mean. I added an item to a comma-delimited file (CSV). The combo box displays the unique idea of each record in the file. i have just added a new record to the file, and I now need the combo box to be updated and display the new record id.
 
I used to load a text file (or CSV) as data source with VB6 using data source name (DSN). Please tell me how to load your CSV file to a list box control.

Anyway, to update your list box, why don't you try to execute the command for loading the file content at the first time? (fill, load?)

Thank's
Inhua
 
Back
Top