cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Balaji_Vinu
Level 5

Populating values into Combo Box

Hi,
I have created a new dialog and added a combo box control in it.
The combo box should be populated from the text file
E.g Populate.txt (Which contains value in the format)
One
Two
Threee

The values should be populated when user clicks on the NEXT button in the previous screen.
Please let me know how can i implement it in Installshield2009 BASIC MSI PROJECT.
How to create an action for Next and a script to populate combo box.
Labels (1)
0 Kudos
(7) Replies
Dan_Galender
Level 10

Take a look at Knowledge Base article Q103295. It covers how to Dynamically Add and Remove Values from a Combo Box at Run Time.
0 Kudos
Balaji_Vinu
Level 5

Hi,

I have used a below vb script in do action of combo box. But i am not getting any values dyanamically loaded to it.

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\MyList.txt", ForReading)

Const ForReading = 1

Dim arrFileLines()
i = 0
Do Until objFile.AtEndOfStream
Redim Preserve arrFileLines(i)
arrFileLines(i) = objFile.ReadLine
i = i + 1
Loop
objFile.Close


For Each strLine in arrFileLines
WScript.Echo strLine
Next


Any info on the above how to get the value populated.
0 Kudos
Balaji_Vinu
Level 5

Hi,
please let me know how to populate the combo box , fetching the data from the text file. I have a sample code which does it. I have pasted it in above post. But i am not sure how to set doAction for running the script to populate.
0 Kudos
TheTraveler
Level 8

This can easily be done in Install Shield script project when you make a custom dialog. If you would like to know how, let me know.
0 Kudos
Reddy611
Level 6

function PopulateListCombo(hMSI)
LIST StringList;
STRING svString, sPath;
NUMBER nResult, nPath;
NUMBER hDatabase, hCBOView, hView, hRec;
STRING szText;
number index, nCount;
STRING sQuery;
STRING hi ;
begin
index=0;
hDatabase=MsiGetActiveDatabase(hMSI);

sQuery="SELECT * FROM ComboBox WHERE Property='PROPNAME'";
nResult = MsiDatabaseOpenView(hDatabase,sQuery,hCBOView);
hRec=MsiCreateRecord(4);

StringList = ListCreate (STRINGLIST);
nResult = LaunchAppAndWait(SUPPORTDIR^"vbs2.exe",hi,LAAW_OPTION_WAIT);
ListAddString(StringList,hi,AFTER);
ListAddString(StringList,"ZAQ",AFTER);
ListAddString(StringList,"FAK",AFTER);
ListAddString(StringList,"MAM",AFTER);

nResult = nResult = ListGetFirstString (StringList, svString);
MsiRecordSetString(hRec,1,'TESTPROP');
MsiRecordSetInteger(hRec,2,index);
MsiRecordSetString(hRec,3,svString);
MsiRecordSetString(hRec,4,svString);

MsiViewModify(hCBOView,MSIMODIFY_INSERT_TEMPORARY,hRec);
nResult = ListGetNextString (StringList, svString);

while (nResult != END_OF_LIST)
index=index+1;
MsiRecordSetString(hRec,1,'TESTPROP');
MsiRecordSetInteger(hRec,2,index);
MsiRecordSetString(hRec,3,svString);
MsiRecordSetString(hRec,4,svString);

MsiViewModify(hCBOView,MSIMODIFY_INSERT_TEMPORARY,hRec);
nResult = ListGetNextString (StringList, svString);
endwhile;

MsiCloseHandle(hRec);
MsiViewClose (hView);
end;
0 Kudos
kiran4545
Level 3

@TheTraveler 

I have got a case where i need to remove my combobox item during runtime. Is there a way where i can do it? I have been struggling to get this work from many days

Use case:

I have got a combobox and i have selected one item from it to do some customaction. In the next dialog i want the combobox item to get removed because i have already used it. So the remaining items needs to show apart from the one i have selected in the previous dialog. 

Is there any piece of code which can make this work ?

Any help is highly appreciated .

0 Kudos

If you have an InstallScript project, have you tried the CtrlSetList function?

https://docs.revenera.com/installshield28helplib/LangRef/LangrefCtrlSetList.htm

Attached is an example. Rename the .txt files to .rul.

HTH

0 Kudos