Results 1 to 17 of 17

Thread: combo box

  1. #1

    Thread Starter
    Fanatic Member zmerlinz's Avatar
    Join Date
    May 2000
    Location
    in a world where the sun always shines on the bloody tv!!
    Posts
    604
    hi

    i have a combo box with 5 options in it

    sound 1
    sound 2
    sound 3
    sound 4
    sound 5

    and i have set the style to 2, but when the program runs the option box is blank, i can't change the text because it is read only with this style option so i was wondering how i could set a default option to be in the combo box when the program runs.

    thanks

    Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
    -- Linus Torvalds

    [Galahtech.com] | [My Site] | [Fishsponge] | [UnixForum.co.uk]

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    In design mode, set the text property to which ever option you want as the default.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3

    Thread Starter
    Fanatic Member zmerlinz's Avatar
    Join Date
    May 2000
    Location
    in a world where the sun always shines on the bloody tv!!
    Posts
    604
    I tried that, but i have set the style to 2 and that means that i can't change it, it says that this is set to read only, if i change the style to 1 then change the text and then change the style back to 2 it still comes up wrong, any more ideas ??

    Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
    -- Linus Torvalds

    [Galahtech.com] | [My Site] | [Fishsponge] | [UnixForum.co.uk]

  4. #4
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    isn't there a Selected property? try
    Code:
    Combo1.Selected(0) = True
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  5. #5

    Thread Starter
    Fanatic Member zmerlinz's Avatar
    Join Date
    May 2000
    Location
    in a world where the sun always shines on the bloody tv!!
    Posts
    604
    No there isn't a selected option, and even if i type it in it still doesn't work, it says method or data member not found, any more ideas

    sorry to be a nuisance

    Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
    -- Linus Torvalds

    [Galahtech.com] | [My Site] | [Fishsponge] | [UnixForum.co.uk]

  6. #6
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    scratch that, use this :
    Code:
    Private Sub Form_Load()
      Combo1.Text = Combo1.List(0) ' where 0 is the index of your default
    End Sub
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  7. #7

    Thread Starter
    Fanatic Member zmerlinz's Avatar
    Join Date
    May 2000
    Location
    in a world where the sun always shines on the bloody tv!!
    Posts
    604
    Guess what,

    Code:
    'text' property is read only
    aaagggghhhhh

    is there a way to do this at all?? i would of thought that your last suggestion would of worked

    Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
    -- Linus Torvalds

    [Galahtech.com] | [My Site] | [Fishsponge] | [UnixForum.co.uk]

  8. #8
    Guest
    Actually, its better to set the ListIndex property because it will actually set an item rather than just change the text.
    Code:
    'Set the 1st item to the default. 
    Combo1.ListIndex = 0

  9. #9
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    its worked for me, and I have the style set to '2' and every thing...
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  10. #10

    Thread Starter
    Fanatic Member zmerlinz's Avatar
    Join Date
    May 2000
    Location
    in a world where the sun always shines on the bloody tv!!
    Posts
    604
    it still doesn't work,

    what could i have done to stop this working,

    here is my code

    Code:
    Combo1.AddItem "sound 1"
    Combo1.AddItem "sound 2"
    Combo1.AddItem "sound 3"
    Combo1.AddItem "sound 4"
    Combo1.AddItem "sound 5"
    
    
    'Code improved by vBulletin Tool (Save as...)
    andi have the style set to 2, what am i doing wrong ??

    Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
    -- Linus Torvalds

    [Galahtech.com] | [My Site] | [Fishsponge] | [UnixForum.co.uk]

  11. #11

    Thread Starter
    Fanatic Member zmerlinz's Avatar
    Join Date
    May 2000
    Location
    in a world where the sun always shines on the bloody tv!!
    Posts
    604
    it ok one of my friends helped me with the problem, i had the code like this

    Code:
    Private Sub Form_Load()
    Combo1.Text = Combo1.List(0)
    Combo1.AddItem "sound 1"
    Combo1.AddItem "sound 2"
    Combo1.AddItem "sound 3"
    Combo1.AddItem "sound 4"
    Combo1.AddItem "sound 5"
    
    End Sub
    
    'Code improved by vBulletin Tool (Save as...)
    instead of like this


    Code:
    Private Sub Form_Load()
    
    Combo1.AddItem "sound 1"
    Combo1.AddItem "sound 2"
    Combo1.AddItem "sound 3"
    Combo1.AddItem "sound 4"
    Combo1.AddItem "sound 5"
    Combo1.Text = Combo1.List(0)
    End Sub
    
    'Code improved by vBulletin Tool (Save as...)
    thanks for all of your help and sorry for being a nuisance

    Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
    -- Linus Torvalds

    [Galahtech.com] | [My Site] | [Fishsponge] | [UnixForum.co.uk]

  12. #12

    Thread Starter
    Fanatic Member zmerlinz's Avatar
    Join Date
    May 2000
    Location
    in a world where the sun always shines on the bloody tv!!
    Posts
    604
    sorry to be a nuisance (again ) but once i have set the default combo item, i would like a way for the program to remeber what the last selection was so that next time the program is run it will have the last one selected as the option

    e.g program runs for the 1st time and "sound 1" is default, the user decides that they like "sound 2" they select this one and close the program, when the program runs next instead of "sound 1 being default" "sound 2" should be.

    sorry if this doesn't make sense, thanks for all of your help

    Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
    -- Linus Torvalds

    [Galahtech.com] | [My Site] | [Fishsponge] | [UnixForum.co.uk]

  13. #13
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    makes sense enough, you can use a file or the registry to store the selected item when the app ends, then open the file/registry key and set it that way instead of hard-coding the 0 in there.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  14. #14

    Thread Starter
    Fanatic Member zmerlinz's Avatar
    Join Date
    May 2000
    Location
    in a world where the sun always shines on the bloody tv!!
    Posts
    604
    again sorry for being a pain, but do you have any code examples ??

    Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
    -- Linus Torvalds

    [Galahtech.com] | [My Site] | [Fishsponge] | [UnixForum.co.uk]

  15. #15
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    i have never used the registry before, but here's a file example...

    Code:
    Private Sub Form_UnLoad()
      Open app.Path & "\data.dat" For Output As #1
        Print #1, Combo1.ListIndex
      Close #1
    End Sub
    
    Private Sub Form_Load()
    
    Dim Index As Integer
    
      If Dir$(app.Path & "\data.dat") <> "" Then
        Open app.Path & "\data.dat" For Input As #1
           Input #1, Index
        Close #1
        
        Combo1.ListIndex = Index
      End If
    End Sub
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  16. #16

    Thread Starter
    Fanatic Member zmerlinz's Avatar
    Join Date
    May 2000
    Location
    in a world where the sun always shines on the bloody tv!!
    Posts
    604
    That is brilliant, thank you very much crptcblade for all of your help and time

    Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
    -- Linus Torvalds

    [Galahtech.com] | [My Site] | [Fishsponge] | [UnixForum.co.uk]

  17. #17
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    no problem
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

Posting Permissions

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



Click Here to Expand Forum to Full Width