Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2012
    Posts
    163

    ComboBox help/sugestion

    Hi, when using the combobox is it possible to use the action;


    if e_Selection==1 then


    but for the "item data" rather than the "index number", I ask as I have a combobox of several hundred entries but adding new ones as testing goes along or in the event of an update then I have to rewrite the script if I sort alphabetically, maybe its there already but I just cant find it in the literature or forums.

    But also can we import a excel or other spreadsheet directly in to the combobox?, if not can you consider adding such a feature?

  2. #2
    Join Date
    Apr 2010
    Posts
    529
    Hey Mick,

    I'm not sure what you're asking in the first part, but couldn't you use something like:

    Code:
    sData = "1"
    ComboBox.FindItem ("ComboBox1", -1, LB_BYDATA, sData)
    ... and tell it which data value to find?

    As for re-sorting when you add more items, do you want to re-order the index #'s on the original list entries, or add the new items at the end of the list (with the cumulative, sequential index #'s) and then sort?

    A simple, example approach, to keep the existing index #'s and add the new ones at the end. Use Combobox.InsertItem and specifying "-1" for the index (to add the item to the end. This will maintain your original index #'s and add the new entries at the end. If you re-sort the CB afterwards, the indexes will still match as per the original insertion index.

    Code:
    index		text		data
    
    1		apples		1
    2		oranges		2
    3		bananas		3
    4		pineapple	4
    Code:
    i = ComboBox.GetCount("ComboBox1");
    Combobox.InsertItem ("Combobox1", -1, "kiwi",  i+1);
    
    
    index		text		data
    
    1		apples		1
    2		oranges		2
    3		bananas		3
    4		pineapple	4
    5		kiwi		5
    Code:
    --Sorted alphabetically:
    
    index		text		data
    
    1		apples		1
    3		bananas		3
    5		kiwi		5
    2		oranges		2
    4		pineapple	4
    If you export your Excel data as a Delimited String and use the DelimitedStringToTable function, you can automate the insertion and numbering process by iterating through the data in the newly created table.

    Are we on track here?

    Cheers,
    MadDogDean

  3. #3
    Join Date
    Feb 2012
    Posts
    163
    @MadDogDean, thanks for that, most helpful and fixed the problem.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts