Jump to content

GUI Combo Box - Select string within Combo


Recommended Posts

Hi 

Simple question: 

A GUI Combo has a list of place names. How do I get the code to select one of the place names using a string and have it be set to the selected place (while still having the ability to change it).

In depth:

I have a combo what contains a list of data from a file_1. in a second file (file_2) is a list of data that might corresponds to file_1. If there is data in file_2 that corresponds to file_1 then I want to set the string in File_2 (the same string is also found in File_1 but along with the other data also) to be the string selected in the combo in the GUI.

File_1 = list of places |place|place|place....

File_2 = the place it was last time (but written differently) , and the single place (written like it is in File_1)

File_3 = the place written differently only.

So File_3 looks at File_2 IF it finds its funny written place it will be converted to the correct way of writing it and then File_2 will selected from the list of places that was entered into the combo from File_1 ELSE if the place is not found in File_2 the user will have to select it manually from the combo.

I want the combo to always be there because File_2 might not always be correct.

$sets = _FileCountLines($File_3)
$data=FileReadLine($File_1,2)
$top=5
For $i=1 To $sets Step 1
    $String = StringSplit(FileReadLine($File_3,$i),",")
    $temp = GUICtrlCreateLabel($String[1]&"  -  "&$String[2],5,$top,($GUIWidth/5)*3-5)
    $Input[$i] = GUICtrlCreateCombo("",($GUIWidth/5)*3,$top,($GUIWidth/5)*2-5,-1,0x0003)
    GUICtrlSetData($Input[$i],$data)
    For $j=1 To _FileCountLines($File_2) Step 1
        $temp2 = StringSplit(FileReadLine($File_2,$j),',')
        If $temp2[1] = $string[3] And $top=1 Then
            GUICtrlSetData($Input[$i],$temp2[2])
        EndIf
    Next
    $top+=30
Next

At the moment the code just adds the place a second time but does not seem to see that the exact same string is already there. 

Link to comment
Share on other sites

Since your snippet is useless and unrunable for us, it will be hard to help you.  We have no idea of the files content (File_1, File_2, File_3).  We have no idea what you are expecting as a result.

If you decide you want help, I strongly suggest you make your request clearer, complete and runable.

Link to comment
Share on other sites

I found a solution.

Using _GUICtrlComboBoxEx_Create(), _GUICtrlComboBoxEx_AddString($string) and _GUICtrlComboBoxEx_SetCurSet()

If $string = the known place name then save to a temp var the index location of the _GUI....._AddString() function then use the _...._SetCurSet($combo,$temp_var_indext_ID).

Sorry it was a supper complex program with files that contain sensitive information so I could not upload it to the point of being about to run it without witting a whole example script.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...