|
-
Feb 7th, 2001, 12:51 PM
#1
Thread Starter
Addicted Member
I am currently using a class that makes an API call to increase the width of my combobox so that the list can be entirely read. I am doing this because space is limited on my form and the only thing the user needs to see is the first two letters. (For example,a list of state abreviations that also shows the full name of the state when it drops down)
So the problem is, the increase in width projects off to the right. When the dropdown event occurrs, the width is too large and it falls off the screen. I need to know if anyone knows how to handle this event so that the increase in width projects to the left. Or any other sugesstions how I can fix the problem. I can't move the combo box to any other position on the form, so thats out.
Thanks for any help you might have.
-
Feb 7th, 2001, 01:15 PM
#2
Addicted Member
Here is something quick i came up with and its very simple:
Code:
Private Sub cboState_DropDown()
cboState.Left = cboState.Left - 600
cboState.Width = cboState.Width + 600
End Sub
Private Sub cboState_LostFocus()
cboState.Width = cboState.Width - 600
cboState.Left = cboState.Left + 600
End Sub
When the drop down event occurs it is expanded to the left and when you loose the focus,
it returns to its original position.
Always looking for a better and faster way!
-
Feb 7th, 2001, 01:17 PM
#3
Addicted Member
ummm...that code has a few bugs in it it works ok though. sorry.
Always looking for a better and faster way!
-
Feb 7th, 2001, 01:21 PM
#4
Addicted Member
this is better:
Code:
Private lngWidth As Long
Private lngLeft As Long
Private Sub cboState_DropDown()
If cboState.Width = lngWidth Then
cboState.Left = lngWidth - 600
cboState.Width = lngLeft + 600
End If
End Sub
Private Sub cboState_LostFocus()
cboState.Width = lngWidth
cboState.Left = lngLeft
End Sub
Private Sub Form_Load()
lngWidth = cboState.Width
lngLeft = cboState.Left
End Sub
hehe
Always looking for a better and faster way!
-
Feb 7th, 2001, 01:33 PM
#5
Thread Starter
Addicted Member
Thanks!
After I saw your first idea, I realized what "bugs' you were talking about and started thinking on the same page as you. I will try the new code, thank you so much. you really helped.
-
Feb 7th, 2001, 01:44 PM
#6
Addicted Member
you know what? that really is a kewl idea! I am going to
see if I can create a ComboBox Control that has 2
properties:
Item Property for the full text item
ShortItem Property for an abreviation of the text
When it is in the normal size, the ShortItem is displayed
and when it is in the expanded state, it didplays the
Item.
Cool idea! It will work great for displaying:
1) States - Florida, FL
2) Names - Mike Rodriguez, MR or Mike R
3) Jobs - Software Engineer, Soft Eng
Always looking for a better and faster way!
-
Feb 7th, 2001, 01:58 PM
#7
Thread Starter
Addicted Member
I think that is a great idea. This problem I am finding, (and maybe you can help with this too), is that when the dropdown event fires, the combo box increases as its supposed to. But when the user selects the item they choose, but doesn't lose focus, the combo box remains the increased width. I doesn't look too pretty. The functionality is exactly what I was looking for, but I'm wondering if there is another event that we can resize it back to normal width upon selection of the list item., instead of waiting for the lost focus event. I don't know of any such event, so I thought maybe you would?????
?????
Thanks-
-
Feb 7th, 2001, 02:03 PM
#8
Addicted Member
oh ya! use the Click Event. It fires when an item is selected
either by the mouse or the keyboard. You could
put the resize code into that event as well.
Always looking for a better and faster way!
-
Feb 7th, 2001, 02:16 PM
#9
Thread Starter
Addicted Member
You are soooo Cool. Thanks. It works and I'm using it.
How about solving this one.....?
If I click on the dropdown, but don't make a change to the selection and i click again, the dropdown goes away but the width doesn't resize. It only resizes on the click event if i select something. So if the user just views the dropdown, but doesn't make a selection, it remains big and still looks a little ugly.
Given, the user will most likely make a selection. I left the code in the lost focus event also to ensure the resizing, but is there something i could do about when the user doesn't make a selection. What event is triggered to tell the dropdown event to not dropdown anymore?
-
Feb 7th, 2001, 02:18 PM
#10
Addicted Member
ummm...hehe ...hold on...ill see what i can to.
Always looking for a better and faster way!
-
Feb 7th, 2001, 02:56 PM
#11
Addicted Member
Always looking for a better and faster way!
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
|