Jump to content
Sign in to follow this  

how to load from text file to ListBox

Recommended Posts

Hey all  :bye:

i need to know how to load from text file to listbox 

i tried to search for it in google. 

and second question : :sweating:

how to move select in list box down

thanks all


sorry if its wrong to make two post in one day .

:sweating:  :sweating:

Edited by LastSoul

Share this post

Link to post
Share on other sites

Hello LastSoul,

First, your description of what you need in the first part is fairly vague. Without any code examples of your attempt just makes it as clear as mud. However:

1. Loading from a text file:

   If you need each line as a separate element, then you could read the file into an array with _FileReadToArray(). If you have a special way to parse your file before adding to the listbox, then use FileRead() and write an algorithm to parse into an array. Use either array with a loop to populate your listbox.

2. Changing selection in a Listbox:

   There are different ways to do this depending on your needs. One of the more simpler would be to use _GUICtrlListBox_FindInText(), which will search for a ListBox item that contains the specified text anywhere in its text. You may also use _GUICtrlListBox_FindString(), which will search for a string. Both of these functions will return the index of it's find from the ListBox. You can then use _GUICtrlListBox_SetCurSel() which will set the focus on the index given.

Your helpfile is your best resource for AutoIt needs. In my opinion, it is one the best written, and user friendly, help file documentations I have ever seen for any language. Check out the 'GuiListBox Management' section in the 'User Defined Functions Reference' to see some very nice examples of things you can do with ListBox.


Edited by Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.  

Share this post

Link to post
Share on other sites

Along with what Realm has suggested, it pays to analyze what you want and divide it up into steps, and then use the Help file, not Google, to understand the requirements of each step.

Save a Google Search (of the AutoIt Forum), for when you are more experienced and more fully understand how to interpret the results you may possibly get. At the very least by then, you should know what questions to ask.

HINT - If you want help here, with code, then provide the code you have already tried ... it helps us immensely ... and you.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.


What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)


Share this post

Link to post
Share on other sites

#include <ListBoxConstants.au3>
#include <GUIConstantsEx.au3>

$hGUI = GUICreate("GUI с элементом списка - List") 

$sText = FileRead(@ScriptFullPath)
$sText = StringReplace($sText, @CRLF, '|')
$sText = StringReplace($sText, '||', '|')

$mylist = GUICtrlCreateList("", 10, 10, 330, 330, $GUI_SS_DEFAULT_LIST + $LBS_NOINTEGRALHEIGHT)
GUICtrlSetData(-1, $sText)


While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...