Results 1 to 5 of 5

Thread: [RESOLVED] combobox limit

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2010
    Posts
    377

    Resolved [RESOLVED] combobox limit

    I want to limit what is inside my combobox. if I choose combobox style to 0, the users can edit in the combobox, if I use 2, yes the user cant edit but when my program load and reads the file with null value for the combobox, there will be error 'Text' properly is read-only.

    any advice.

  2. #2
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: combobox limit

    Just leave the style as 0 and inhibit entry through the KeyPress event and inhibit through the Change event so the user can't copy and paste into it
    Code:
    Private Sub Combo_Change()
    Combo.Text = Combo.List(Combo.ListIndex) ' or any other listitem
    End Sub
    
    Private Sub Combo_KeyPress(KeyAscii As Integer)
    KeyAscii = 0
    End Sub
    
    Private Sub Form_Load()
    Combo.AddItem "Fred"
    Combo.AddItem "Bert"
    End Sub

  3. #3
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: combobox limit

    Why not just handle null situations? Leave the style at 2. If you have to reference a null value, set the combobox .ListIndex to -1
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  4. #4
    Hyperactive Member
    Join Date
    Jan 2006
    Location
    Pakistan
    Posts
    388

    Re: combobox limit

    La Volpe gives the easier choice, in my opinion.

    Plus, what do you mean by "my program load and reads the file with null value for the combobox"? Can you post the code for this part so that we can modify it for you?
    If your problem is solved, then drag down the Thread Tools and mark your thread as Resolved.

    If I helped you solve your problem, inflate some air into my ego by rating my post and adding a comment too.

    For notorious issues (elaborate yourself) contact me via PM. I don't answer them in the forums EVER.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2010
    Posts
    377

    Re: combobox limit

    Thanks Doogle, Lavolpe and Ione Rebel.

    I opt to use Doogle suggestion for now. I tested the suggestion of Lavolpe but it still persist. I am reading an ini file with null value for a certain section.

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