Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

List box properties and filling dynamically


1 reply to this topic

TimI

TimI
  • Members
  • 10 posts

Posted 05 February 2002 - 01:14

[rant] I am trying to do something that should be quite simple, but as it always seems with IS, it appears to be a pain. [/rant]

I would like to create a list box on a custom dialog, fill it with data provided at runtime, select a default item (again at runtime) and get the selected item back.

First off, I do not see either the PROPERTY or ITEMS field listed in the Property/Value list control (as they I would expect them from the documentation).

After I figure out how to set the PROPERTY value, I will need to fill the list box during run time. I found this ISS KB article, and it seems to require setting up a property for each item, which would be frustrating, since I'd like the number of items to be dynamic.

In IS 5.0, this was accomplished via a custom dialog and CtrlSetList.


Ken B

Ken B
  • Members
  • 2 posts

Posted 12 February 2002 - 04:53

The following code will populate a listbox with the PROPERTY of REQLISTBOX.  You will need to retrieve the information that you would like to display and substitute it for the ListAddString value.  The example has hard coded values.  I have tested this and it correctly populates the list box.  I am not exactly sure what you meant by selecting a default item and then get the item back?  Hope this helps.

listID = ListCreate(STRINGLIST);
   if (listID = LIST_NULL) then
   MessageBox("Unable to create list", SEVERE);
   abort;
   endif;
   
   szQuery = "Select * FROM ListBox";
   hDatabase = MsiGetActiveDatabase(hMSI);
   nReturn = MsiDatabaseOpenView(hDatabase, szQuery, hView);
   
  szPropertyValue = "test";
  szPropertyValue1 = "test1";
  szPropertyValue2 = "test2";
   
   
       ListAddString(listID, szPropertyValue, AFTER);
       ListAddString(listID, szPropertyValue1, AFTER);
       ListAddString(listID, szPropertyValue2, AFTER);
       
   nSize = ListCount(listID);
   cnt = 1;
   ListGetFirstString ( listID , svString );  
   while (cnt <= nSize)
   ListCurrentString(listID, svString);
   nOrder = cnt;
   szText = svString;
   svValue = szText;
   szProperty = "REQLISTBOX";
   hRecord = MsiCreateRecord(4);
   MsiRecordSetString(hRecord, 1, szProperty);
   MsiRecordSetInteger(hRecord, 2, nOrder);
   MsiRecordSetString(hRecord, 3, svValue);
   MsiRecordSetString(hRecord, 4, szText);
   nReturn = MsiViewModify(hView, MODIFY_INSERT_TEMPORARY, hRecord);
   cnt=cnt + 1;
   ListGetNextString ( listID , vString );
   endwhile;
   


end;