|
-
Nov 21st, 2011, 02:15 AM
#1
Thread Starter
Hyperactive Member
[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.
-
Nov 21st, 2011, 03:08 AM
#2
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
-
Nov 21st, 2011, 09:01 AM
#3
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
-
Nov 21st, 2011, 02:03 PM
#4
Hyperactive Member
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.
-
Nov 21st, 2011, 07:09 PM
#5
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|