Announcement

Collapse
No announcement yet.

How to stop a Combobox from displaying sorted strings

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to stop a Combobox from displaying sorted strings

    I coded my dialog with the below code

    Code:
    LOCAL  NBarArr()  AS STRING
      REDIM NBarArr(1 TO 8)
        ARRAY ASSIGN NBarArr() = "   4", "   6", "   8",_
              "   10" , "   12" , "   14","   16" , "  18"  
    
    ​  CONTROL ADD LABEL, hDlg, %ID_LabNBar , "Number of Bars "  , 60, 225 , 115 , 18
          CONTROL ADD COMBOBOX, hDlg, %ID_CmbNBar, NBarArr(), 150,225 , 60,20
        ​

    but on the screen, the combobox shows sorted

    Click image for larger version

Name:	Number bar.png
Views:	100
Size:	4.0 KB
ID:	820763


    Which is incorrect as I need the combobox to display in the order of 4 --> 6 ---> 8 --> 10 --> 12 .......

    How to I get it display in the order the array was assigned?


  • #2
    Found that the default combobox's style is %CBS_SORT

    Is there a style to set the combobox to display unsorted and to present elements in the same order as it was assigned ?

    Comment


    • #3
      I think you answered your own question... don't include %CBS_SORT.
      The default combo box style comprises %CBS_DROPDOWN, %CBS_SORT, and %WS_TABSTOP

      Comment


      • #4
        This should work...
        Code:
        CONTROL ADD COMBOBOX, hDlg, %ID_CmbNBar, NBarArr(), 150,225 , 60,20, %CBS_DROPDOWN OR %WS_TABSTOP

        Comment


        • #5
          Originally posted by Tim Lakinir View Post
          Found that the default combobox's style is %CBS_SORT

          Is there a style to set the combobox to display unsorted and to present elements in the same order as it was assigned ?

          Just set the styles yourself without the %CB_SORT.

          Try something like %CBS_DROPDOWNLIST OR %WS_TABSTOP

          Comment


          • #6
            Thank you Frank and Stuart, I just specified in the combobox style straightaway and it works!

            Code:
             CONTROL ADD LABEL, hbDlg, %ID_LabNBar , "Number of Bars "  , 60, 245 , 115 , 18
                  CONTROL ADD COMBOBOX, hbDlg, %ID_CmbNBar, NBarArr(), 150,245 , 60,20 ,_
                    %CBS_DROPDOWN OR %WS_TABSTOP
                  COMBOBOX SELECT hbDlg, %ID_CmbNBar, 1    ​

            Comment


            • #7
              Originally posted by Tim Lakinir View Post
              Found that the default combobox's style is %CBS_SORT

              Is there a style to set the combobox to display unsorted and to present elements in the same order as it was assigned ?
              Note that "default" style in PB is just a common set of styles that Bob decided to implement in DDT by default to make it quicker and simpler to create objects most of the time, including %CB_SORT for comboboxes. (i.e. in many cases, you don't need to specify any styles when you add a dialog or control).

              As soon as you want any behaviour other than the DDT default, you set all of the styles you want the object to have, just as you would when using the API directly to create them.

              Comment


              • #8
                In Help the default styles are shown in bold. To not use a style (%CBS_SORT in this case) but keep the rest of the defaults, OR in the others shown in bold.

                Cheers,
                Dale

                Comment

                Working...
                X