bwk5502
09-04-2000, 10:41 PM
I have cboBox1 of style 2 on form1. For my application I want this box to have style 2 only. The cboBox1.AddItem stuff works just fine, and the user can select items from the dropdown list. But, within my program code in form_load(), how do I put "sometext" directly in the box for cboBox1? Or, how do I tell the box to show the contents refered to by an index number? cboBox1.text = "sometext" does not work.??? I can do it for style 0, but not for style 2.
anhmytran
09-05-2000, 12:21 AM
1- How to tell Combo Box display its text:
Copy the following code into a blank experimental project that has only a combo box:
Private Sub Form_Load()
With Combo1
.AddItem "AAAA"
.AddItem "BBBB"
.AddItem "CCCC"
.AddItem "DDDD"
End With
End Sub
Private Sub Form_Click()
Static i As Integer
If i = Combo1.ListCount Then i = 0
Combo1.Text = Combo1.List(i)
i = i + 1
End Sub
2 - You can do something with Combo box style 0 but not other styles:
Because their nature, created by MS, as we individuals created by God. Each object is unique by itself.
AnhMy_Tran
bwk5502
09-05-2000, 12:29 AM
Golly! I've never seen a "With" statement before. Live and learn.
Thanks. I'll try the rest later.
d.paulson
09-05-2000, 12:29 AM
You can go combo1.text = "sometext" as long as "sometext" is an item in the combo list
d. paulson
bwk5502
09-05-2000, 11:03 AM
Yes, That was my problem. Changed the code and now it works.
Thanks a bunch.