Comboxgadet sorted numeric

Just starting out? Need help? Post your questions and find answers here.
Little_man
Enthusiast
Enthusiast
Posts: 143
Joined: Fri Mar 29, 2013 4:55 pm
Location: The Netherland

Comboxgadet sorted numeric

Post by Little_man »

Is it possible to sort a combox gadget numerically ( from 1 to 1000)

(Result example: 1, 2, 3, 4, 5, ...... 1000)

Code: Select all

If OpenWindow(0, 100, 130, 220, 100, "ComboBox Sorted", #PB_Window_SystemMenu)
    cb.l = ComboBoxGadget(1, 10, 10, 200, 20, #CBS_SORT) 
    
    For dlInc = 1 To 100
      SendMessage_(cb, #CB_ADDSTRING, 0, Str(Random(500, 1)))
    Next

  Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
Little_man
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4664
Joined: Sun Apr 12, 2009 6:27 am

Re: Comboxgadet sorted numeric

Post by RASHAD »

Hi
It's sorted already
But I think you want the sorting style to be (Natural)

Code: Select all

If OpenWindow(0, 100, 130, 220, 100, "ComboBox Sorted", #PB_Window_SystemMenu)
    cb.l = ComboBoxGadget(1, 10, 10, 200, 20,#CBS_SORT)
    
    For dlInc = 0 To 100
      SendMessage_(cb, #CB_ADDSTRING, 0, RSet(Str(Random(500, 1)),3,"0"))
    Next
    
    For dlInc = 0 To 100
      text$ = LTrim(GetGadgetItemText(1,dlInc),"0")
      SetGadgetItemText(1,dlInc,text$)
    Next
    
  Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
Egypt my love
Little_man
Enthusiast
Enthusiast
Posts: 143
Joined: Fri Mar 29, 2013 4:55 pm
Location: The Netherland

Re: Comboxgadet sorted numeric

Post by Little_man »

Thanks "RASHAD" for your information.

Little_man
Post Reply