[Gambas-user] Problem with listbox

MaxVK maximvonk at ...626...
Tue Jan 29 14:17:29 CET 2008


Hi Timothy. Could you expand this explanation to cover Gambas 2 please.

Thanks

Max


TimothyMN wrote:
> 
> 
> Hello Juanra,
> 
> In Gambas 1 the List property of a ListBox was a string and each item in
> the ListBox was separated by a new line. In Gambas 2 this has been
> changed to a string array. So it is not that difficult to convert your
> code to gambas 2.
> 
> These examples show how you can open and save the content of a ListBox
> to a text file.
> 
> Note that that there is at least one defect with these methods. If any
> item strings in the ListBox contain new lines than they will be split
> into two lines. Maybe not what you want.
> 
> 
> ' Open a text file for display in the ListBox
> PUBLIC SUB ToolButtonOpen_Click()
>   Dialog.Filter = ["Lists (*.lst)", "Text Files (*.txt)", "All Files
> (*)"]
>   IF Dialog.OpenFile() THEN RETURN
>   ListBox1.List = Split(File.Load(Dialog.Path), "\n")
> CATCH
>   Message.Info("Cannot load list:<br>" & Dialog.Path & "<hr>" &
> Error.Text)
> END
> 
> ' Save the ListBox content to a text file
> PUBLIC SUB ToolButtonSave_Click()
>   Dialog.Filter = ["Lists (*.lst)", "Text Files (*.txt)", "All Files
> (*)"]
>   IF Dialog.SaveFile() THEN RETURN
>   File.Save(Dialog.Path, ListBox1.List.Join("\n"))
> CATCH
>   Message.Info("Cannot save list:<br>" & Dialog.Path & "<hr>" &
> Error.Text)
> END
> 
> 
> Will this email make it? We shall see if I have been blacklisted form
> source forge. Or may be it was to many people voting for Gambas.
> 
> Thanks
> 
> 8-{)} Timothy Marshal-Nichols
> <mailto: timothy.marshal-nichols at ...247...>
> 

-- 
View this message in context: http://www.nabble.com/Problem-with-listbox-tp11133645p15159202.html
Sent from the gambas-user mailing list archive at Nabble.com.





More information about the User mailing list