
Originally Posted by
ppl2pass
nextgen1 i promise its going to be my last topic for today. please dont delete
ok so how do i refresh a combo-box with the options still there.
the long way:
clear the com

x1
and add the items back in again.
is there a simpler methodÉ
Yes, you can do it by saving the contents of the combo-box to a file. Clear the items and then reload.
Here's what you need to do:
Create a sub that will save and clear the items of the combo-box:
[php]Sub SaveAndClear()
Dim finalstr As String = ""
For Each n As String In Combo-Box1.Items
finalstr += n & vbCrLf
Next
My.Computer.FileSystem.WriteAllText(My.Computer.Fi leSystem.SpecialDirectories.MyDocuments & "\temp.xxx", finalstr, False)
Combo-Box1.Items.Clear()
End Sub[/php]
Then create a sub to reload the items:
[php]Sub reload()
If My.Computer.FileSystem.FileExists(My.Computer.File System.SpecialDirectories.MyDocuments & "\temp.xxx") Then
Dim n As String = My.Computer.FileSystem.ReadAllText(My.Computer.Fil eSystem.SpecialDirectories.MyDocuments & "\temp.xxx")
Dim x() As String = n.Split(ChrW(10))
For Each z As String In x
If Not z = vbNullString Then
Combo-Box1.Items.Add(z.Trim)
End If
Next
End If
End Sub[/php]
Finally call the subs as required:
For example I call them through buttons:
[php]Private Sub refresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SaveAndClear()
End Sub
Private Sub ReloadItems_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReloadItems.Click
reload()
End Sub[/php]
I hope this helps !!