Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
ComboBox Problem
I have a form that on loading Sets Focus to the only combobox on the
form. THe combobox initially starts out either blank or with text, and always has the same list of values. However, when the combox box starts out empty, there is no cursor inside of it so I can't just start typing text. How do I fix this? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
ComboBox Problem
I put a combobox on a userform with several controls. The combobox had no
data in the list. I set the TabIndex property to 0 and when I showed the form, the cursor was blinking in the combobox. If you are using some other method, don't. -- Regards, Tom Ogilvy "R Avery" wrote in message ... I have a form that on loading Sets Focus to the only combobox on the form. THe combobox initially starts out either blank or with text, and always has the same list of values. However, when the combox box starts out empty, there is no cursor inside of it so I can't just start typing text. How do I fix this? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
ComboBox Problem
I figured out the problem, but it sure took a while. I tried your
suggestion, and it worked, for the first time only. Any subsequent ..Show's of the form did not have the cursor in the combobox. However, when I tried to replicate my experience in a new simple form, I got the same behavior. I solved this for the simple form by doing an Unload Form1 before showing the form each time, and it worked perfectly. However, that did not work for my form. It turns out that I had disabled the form QueryClose event by always setting the Cancel parameter to TRUE. After removing that code, the form was properly unloaded from memory, and when shown again, the cursor is properly inside the combobox. However, suppose in the future, I desire the capability to select a ComboBox programmatically and select all text inside (or put the cursor inside, if no item has been chosen). How would one do that? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
ComboBox Problem
Private Sub Userform_Activate()
ComboBox1.SetFocus If ComboBox1.Text = "" Then ComboBox1.SelStart = 0 Else ComboBox1.SelStart = 0 ComboBox1.SelLength = Len(ComboBox1.Text) End If End Sub is a possibility. Worked for me with hiding the form. -- Regards, Tom Ogilvy "R Avery" wrote in message ... I figured out the problem, but it sure took a while. I tried your suggestion, and it worked, for the first time only. Any subsequent .Show's of the form did not have the cursor in the combobox. However, when I tried to replicate my experience in a new simple form, I got the same behavior. I solved this for the simple form by doing an Unload Form1 before showing the form each time, and it worked perfectly. However, that did not work for my form. It turns out that I had disabled the form QueryClose event by always setting the Cancel parameter to TRUE. After removing that code, the form was properly unloaded from memory, and when shown again, the cursor is properly inside the combobox. However, suppose in the future, I desire the capability to select a ComboBox programmatically and select all text inside (or put the cursor inside, if no item has been chosen). How would one do that? |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
ComboBox Problem
I tried something similar to this before, and it did not work. However,
this code does work. I'm not sure why my code didn't work, but thanks so much, Tom! This form now works great. Tom Ogilvy wrote: Private Sub Userform_Activate() ComboBox1.SetFocus If ComboBox1.Text = "" Then ComboBox1.SelStart = 0 Else ComboBox1.SelStart = 0 ComboBox1.SelLength = Len(ComboBox1.Text) End If End Sub is a possibility. Worked for me with hiding the form. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
ComboBox problem | Excel Discussion (Misc queries) | |||
Combobox Problem | Excel Programming | |||
Combobox Problem | Excel Programming | |||
Combobox problem | Excel Programming | |||
ComboBox Problem | Excel Programming |