![]() |
New to ComboBox
Hi:
I have a ComboBox called cboList. My code follows: ------------------------------------------------------- 1 ------------------------------------------------------- Private Sub cboList_DropButtonClick() Dim arr(1 To 2) As String Dim i As Integer arr(1) = "Test1" arr(2) = "Test2" cboPortfolioList.Clear For i = 1 To 2 cboPortfolioList.AddItem arr(i) Next i End Sub The DropButtonClick funttion works just fine. But when I tried to select a value, I could't see the selected value in the ComboBox. I tried to use Application.ScreenUpdating = True to see what's happening. It seemed that my selected value appeared for 1/1000 sec and then dissapeared. I also tried the following, which also failed: ------------------------------------------------------- 2 ------------------------------------------------------ Private Sub cboList_Change() Select Case cboList.Value Case 0 cboList.Text = "Test1" Case 1 cboList.Text = "Test2" End Select End Sub Following code works: --------------------------------------------------------- 3 -------------------------------------------------------- Private Sub cboList_Change() Select Case cboList.Value Case 0 cboList.Text = "Test 1" Case 1 cboList.Text = "Test 2" End Select End Sub NOTICE the string values in the third code are with space, i.e. "Test 1" and not "Test1". In another word, the text property works if the assigned value is not equal to the value property. My question is how can I make my selection permanently visible? Shouldn't the ComboBox control automatically change its value to user's selection? and why does the text property only work if its value is different from the value property? Regards, Adrian T |
New to ComboBox
I would drop all that code an initialize the combobox when the userform is
displayed Private Sub Userform_Initialize() Dim arr(1 To 2) As String Dim i As Integer arr(1) = "Test1" arr(2) = "Test2" cboPortfolioList.Clear For i = 1 To 2 cboPortfolioList.AddItem arr(i) Next i End Sub -- Regards, Tom Ogilvy "Adrian T" wrote in message ... Hi: I have a ComboBox called cboList. My code follows: ------------------------------------------------------- 1 ------------------------------------------------------- Private Sub cboList_DropButtonClick() Dim arr(1 To 2) As String Dim i As Integer arr(1) = "Test1" arr(2) = "Test2" cboPortfolioList.Clear For i = 1 To 2 cboPortfolioList.AddItem arr(i) Next i End Sub The DropButtonClick funttion works just fine. But when I tried to select a value, I could't see the selected value in the ComboBox. I tried to use Application.ScreenUpdating = True to see what's happening. It seemed that my selected value appeared for 1/1000 sec and then dissapeared. I also tried the following, which also failed: ------------------------------------------------------- 2 ------------------------------------------------------ Private Sub cboList_Change() Select Case cboList.Value Case 0 cboList.Text = "Test1" Case 1 cboList.Text = "Test2" End Select End Sub Following code works: --------------------------------------------------------- 3 -------------------------------------------------------- Private Sub cboList_Change() Select Case cboList.Value Case 0 cboList.Text = "Test 1" Case 1 cboList.Text = "Test 2" End Select End Sub NOTICE the string values in the third code are with space, i.e. "Test 1" and not "Test1". In another word, the text property works if the assigned value is not equal to the value property. My question is how can I make my selection permanently visible? Shouldn't the ComboBox control automatically change its value to user's selection? and why does the text property only work if its value is different from the value property? Regards, Adrian T |
All times are GMT +1. The time now is 06:13 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com