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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to make a Header/Title Bar for a Combo Box

Status
Not open for further replies.

networkthis

Programmer
Jul 11, 2011
29
US
I have a combo box that has 5 columns and it needs to have a Header/Title Bar to describe the columns. Is it possible to add that feature easily - the control has to remain on the form as a combo box.
 
No, the combobx has no header. Why not Place Labels on top? Or buttons?

Bye, Olaf.
 
An obvious way of doing this would be to add a label - or maybe five labels - just above the combo box. Provided you took care to arrange it so that the captions lined up properly with the columns, it should achieve the result you want. It might also be useful to adjust the foreground and background colours of the label(s) to make it look more obviously part of the combo.

Going further, if this was something you are likely to do more than once, you can create your own "combo with header" class. This would be a container object, holding both the labels and the combo box. The advantage is that it will bind the two controls together, allowing you to operate on them as a single unit.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks for the info, I was hoping I just overlooked the obvious.... I can use a label/labels, but now my issue is this combo box drops down and to the left because of it's position on the page. Is it possible to bind the label to the top left position of the drop portion of the combobox? Or to get the coordinates of the dropped portion of the combobox?
 
If the combo is always in the same position on the form, and if the user never resizes the form, then the fact that it drops down to the left shouldn't make any difference. The labels will always be in the same position relative the combo.

But even if that wasn't the case, you can always find the positions of the columns dynamically. You would explicitly set the column widths by means of the combo's ColumnWidths property. You know the co-ordinates the right-hand edge of the combo (by adding its Left to its Width). That's all you need to calculate where each column begins and ends (except perhaps for a minor adjustment to allow for the combo's border and the the vertical lines between the columns).

This is all an argument in favour of using the custom combo-with-labels container class that I suggested earlier. That way, you can encapsulate the necessary calculations at the class level, and not have to worry about them when designing the form.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top