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

DBLookupComboBox Column Widths

Status
Not open for further replies.

FrankThynne

Technical User
May 29, 2001
36
0
0
GB
Can I control the column widths of a DBLookupComboBox without changing the Field properties of its ListSource (which might be used by two or more slightly different combos)?
 
hi,

Its just one of the properties

TDBLookupComboBox.DropDownWidth := Length(field)*10

Steph [bigglasses]
 
Thanks Steph, but that's not the problem. It's the individual column widths I wanted to change, not the total width.

I tend to use combo boxes with 2 or 3 columns and hide the key field if it has no user significance. I had wanted to use the same list source for more than one combo, but with different sets or sequences of columns for different circumstances. Sometimes I need to refer to invisible columns.

Perhaps I should just move the columns I want to hide so that they lie beyond the drop down width.

Frank
 
Hi Frank
Just Thought Id let you know your not alone...
I have a similar problem

You could link your DBLookup to a SQL of the table (with just the relevant fields) rather than the table itself.

The column widths seem to default to the field sizes that your columns are allocated to..
This is not Font Size dependant though, so the problem I get is that the end of fields are chopped off if I use a larger font.. DOH!

In VB you could specify a value for each column seperated by a ; or a : maybe that might help.. I haven't tried it myself yet.

If you get a solution please let me know...

Cheers
Glyn
 
Dam - sorry just realised that its the wrong component ;-). Still Interesting code though.

Opp.
 
Hi Glyn. Yes, I'm already using SQL rather than the whole table(s). I just hoped that I wouldn't need to have scores of different queries! As for the font size problem, I suppose you could adjust the size of the dataset columns at run time in proportion to the font size relative to the 'standard' size. And, yes, I've worked with MS Access (wash my mouth out!) but tweaking controls is very easy in that. Column widths are, indeed, lists separated with semicolons.

and Hi, Opp. The article is interesting. I've already played with subclassing TDBGrid and might add this to it. Pity about TDBLookupComboBox, though. I see there are some third party replacements about, but I'm trying to stick with standard Delphi as much as possible.
 
Hi Opp,
I had a look at the articles and they, too, deal only with the overall drop-down width and not with the widths of the individual columns.

For the moment I'll be using separate datasets for each combo and using field sizes to determine column widths.

In future I'll try to adjust these at run time to deal with font sizes, and then possibly produce a better component that handles drop-down column widths like Access/VB.

Thanks for your interest in this subject.
Frank
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top