CompuServe Thread

#Combo Box List Width

7 messages in this thread
#2173From: TASC-MLSOct 9, 1991 8:17 AM
Hi, Does anyone know if there is a way to get the combo box pulldown list to size itself to the width of the longest string in the list. I have an application where I want to show the users a one character code followed by a description of the code in the pulldown list. When they pick from the list, I'll just enter the one character code into the box for them. The combobox itself is sized to show only a single character and when I pull down the list, the list box only extends to the end of the control thus truncating my descriptions. Any help would be appreciated. Thanks. — Rich Cuti There are 2 Replies.
#2183From: Dennis L. HarringtonOct 9, 1991 10:17 AM
Rich, Take a look at the .width property for your combobox. I haven't tried it but you should be able to reset the width of the combobox to the width needed for the descriptions when it's initially selected. Then reset the width back to the original once a new selection has been made. –dennis There is 1 Reply.
#2405From: TASC-MLSOct 10, 1991 9:57 AM
Thanks. I might have a problem with this soln since I have controls next to it and thus if I change the width of the combobox it will overlap other controls which I thought was a big no no for VB. I'll see what happens. Thanks. — Rich Cuti
#2281From: Don FunkOct 9, 1991 6:27 PM
Hi, I did a quick sample code for style 2 combobox. This should get you on your way. Look in the Knowledge Base for information on the GetSystemMetrics for additional parameters. Don Funk Const SM_CYCAPTION = 4 Sub Form_Click () S% = TextWidth("AA") X% = GetSystemMetrics(SM_CYCAPTION) If Combo1.Style = 2 Then Combo1.Move 10, 10, S% + X% End If Combo1.AddItem "AA" End Sub There are 2 Replies.
#2404From: TASC-MLSOct 10, 1991 9:55 AM
Thanks. I'll try it. Does this work with style 0? I need my combo boxes to have an edit area too. — Rich Cuti There is 1 Reply.
#2447From: Don FunkOct 10, 1991 12:33 PM
Hi Rich, I did the easiest one<g>. You will need to figure what the white space is between the button and edit portion. As a quick solution which may not work on all systems is to just add some constant which will account for this space. Different systems may have different "white space". Don Funk
#2419From: TASC-MLSOct 10, 1991 10:24 AM
Hi, I gave both solns a try (yours and Dennis's) and they did resize the comboboxes but as I feared, they overlap other controls (this is a data entry type form I'm building) and thus mess up each other. I need the list to expand to width without the actual control width changing. I guess I may have to build my own "pop-up" form from a list box to do what I want. I'll see. Thanks guys. — Rich Cuti