Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enlarge the combo.List width property...

Status
Not open for further replies.

markSaunders

Programmer
Jun 23, 2000
196
GB
Problems with displaying the full text of the list contents in combo boxes? this little code enables you to define the width of the list section of a combo box (similar to the access type of combos) as a percentage. values of less than 100 are automatically forced to be 100(%).

this code was picked up along my travels (source not recorded)

if anyone manages to wrap up this functionality with the normal vbCombo control then please let me have a copy! i wrapped up a combo box with an added property of [tt].widthList[/tt] but ran into many problems trying to get other properties such as [tt].Style[/tt], [tt].List[/tt] and [tt].Index[/tt] to function as per the 'normal' vbCombo.


[tt]Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg _
As Long, ByVal wParam As Long, lParam As Any) As Long


Private Sub SetComboWidth(cboCombo As ComboBox, lngSetWidth _
As Long)
SendMessage cboCombo.hWnd, &H160, lngSetWidth, 0&
End Sub[/tt]
[sig]<p> Mark Saunders<br><a href=mailto: > </a><br><a href= Solutions</a><br> [/sig]
 
Mark,
Maybe you know this already and the problems you had with the combo's regular properties came from something else. True inheritance is not supported in vb (yet, this will change with VB.NET) so when you create a new control based on an existing one you have to map each property in your new control to the underlying property in the new control. In other words you have to write a property in your control for each property you want to use, even if it already exists in the regular combo box.

Also, i came across some code at that allows you to call one function with one parameter (the combo box to change) and have the width of the drop down list (not the text portion of the combo) change to fit the longest string. You might want to look at that and see how it compares to what you have. [sig]<p>Ruairi<br><a href=mailto:ruairi@logsoftware.com>ruairi@logsoftware.com</a><br>[/sig]
 
cheers for the link. i sussed the problems with lack of OO in terms of having to pass through the properties and events, but couldnt work out how to 'pass through' such as the [tt]list[/tt] and [tt]listIndex[/tt] properties.

the control you've referenced contains most of the code to acitivate the expected properties of the combo control but, i note, not the [tt]list[/tt] property, still - this looks like the best one i've seen thus far. cheers. ::) [sig]<p> Mark Saunders
 


How can move the letter from the form AUTOMATICALLY?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top