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

width of combo box dropdown 2

Status
Not open for further replies.

beedubau

Programmer
Jan 7, 2003
97
AU
How can I restrict the length of the dropdown list in a combobox. Such as with KEYBOARD '{F4}'

It comes out as the full field length ( a filepath ) where the paths table has a field length of 254.This is there in case a VERY long path structure is chosen. ( Genealogists have these).

But I would only want to show that width if an entry used that number of chrs.

I would like the width to be equal to the longest path only.

Regards

bryan
 
Look at help on "ColumnWidths Property "
The units are not characters but units specified elsewhere.
wjwjr
 
Bryan,

As Mr White says, you use the ColumnWidths property to specify the width of the drop-down portion.

However, that might not fully meet your requirements. You say that you want to show the full width of the longest path. In other words, you want to dynamically control the width according to the data being displayed.

Although it's possible to programmatically change the ColumnWidths property, the problem is that ColumnWidths is expressed in pixels, so you would need to convert your data widths (in characters) to pixels, which is tricky.

A better solution might be to restrict the ColumnWidths to some fairly typical value, and to set the combo's ItemTips to .T. That way, the user will still see the full path, but the programming will be much easier.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
I had a value of 395 for 'ColumnWidths'- I changed this to 200 .

Correct result.

Then back to 395 and it stayed at 200.

I have then made ridiculously long folder names and I find that Windows has a limit in th total number of chrs in a path.

Then I find that the drop down ( which was truncated after the first short path now has spread right across my 2 screens.


Regards

Bryan
 
You could do something like this:
Code:
****ComboBox.Init()
If !Pemstatus(This,"cFontsize",5)
	This.AddProperty("cFontsize",Fontmetric(6,This.FontName,This.FontSize))
Endif

**** Where you populate the combobox
**** For this Example:
***Table = Customer
***rowsource = customer.address
Calculate Max(Len(Alltrim(address))) To nColumnWidth
This.ColumnWidth = (nColumnWidth * This.cFontsize)+This.cFontsize
This.Init()
You will have to fine tune...
 
Imaginecorp,

I put some variables to watch in the debugger - this does do what i wanted.

Code:
z = INT(VAL(this.ColumnWidths))
x = FONTMETRIC(6,THIS.FONTNAME,THIS.FONTSIZE)
IF !PEMSTATUS(THIS,"cFontsize",5)
	THIS.ADDPROPERTY("cFontsize",x)
ENDIF
SELECT mypaths
nColumnWidth = 1  && Initialize minimum value

SCAN
  Calculate Max(Len(Alltrim(mypaths.MyPath))) To nColumnWidth
ENDSCAN

z = nColumnWidth
this.ColumnWidths = TRANSFORM((z * x)+x)
THIS.INIT()

&& Note ColumnWidths

Many thanks.

I would like to know the absolute length of a path in Windows XP - as I said after making my third long test foldername it refused a 4th until I made it shorter.

Regards

Bryan
 
Bryan,

I would like to know the absolute length of a path in Windows XP

I believe the maximum for path + file is 260 characters. The maximum for just the filename is 248 characters. (This is from memory.)

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thank You. Glad I could help.

You do not need a Scan...Endscan as Calculate Max() will run through the complete table.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top