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!

Problem with combo propdown

Status
Not open for further replies.

coldan

Programmer
Oct 19, 2008
98
AU
I have a table of paths used in my app which the user can access via a combo on the main form.

When the down arrow is clicked the drop down 'panel' of entries is far too wide.

How can I shorten this to the width of the control itself?

See
Thanks

Coldan
 
Coldan,

Ah, a nice easy question to start the day.

To change the width of the dropdown portion, set the ColumnWidths property. Note this this is a character string, not an integer.

Example:

Code:
* Set width to 50 pixels
THISFORM.Combo1.ColumnWidths = "50"

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Hi Mike,

I had this columwidths set to 250 in the propoerties of the combo as that is the chr in the field (254) to allow for very long path names.

I tried

Changing this value to 50 - no change
Adding a line in the forms init - no change
Cleared out the 250 in the properties with line in init - no change.

I think I tried these things some years ago when I first started the app.

The dropdown width also seems to vary - based on what I don't know. - it sometimes is way outside the form itself let alone the combo.

Sorry to spoil your day already.

Thanks

Coldan
 
Coldan,

Oh, well, you can't get them all right.

I should have mentioned that the ColumnWidths property only works if ColumnCount is more than 1. Can you try adding a second column to the combo; keep it empty; and set ColumnCounts to something like "200,0". That might work.

Also, you said you set the ColumnWidths to 250 because the field is C(254). In fact, ColumnWidths is expressed in pixels, not characters.

Let me know if that helps at all.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
You should either use the ColumnWidths property or trim at source. If you use ColumnWidths though, there is a catch. You need to use a columncount > 1. ie:

Code:
Public oForm
oForm = Createobject('comboSample')
oForm.Show

Define Class ComboSample As Form
  DataSession = 2
  Height=300
  Width =600
  Add Object cmbSample As ComboBox With ;
    Top = 10,Left = 10, Width = 500, ;
    RowSourceType = 3, ;
    RowSource = 'SELECT filePath, fileId  from myFilePaths into cursor xx', ;
    ColumnCount = 2, ColumnWidths = '500,0', ColumnLines = .F., ItemTips = .T.

  Procedure Load
    Create Cursor myFilePaths (fileID i Autoinc Nextvalue 1 Step 1, filePath c(250))
    Local ix
    Local Array laFiles[1]
    For ix = 1 To Adir(laFiles, _samples+'solution\forms\graphics\*.*')
      Insert Into myFilePaths (filePath) ;
        VALUES ( _samples+'solution\forms\graphics\'+laFiles[m.ix,1] )
    Endfor
  Endproc
Enddefine

Cetin Basoz
MS Foxpro MVP, MCP
 
You could use a row source type of SQL Statment and constrict your data in the sql.

select substr(mycolumn,1,50) as desc, key, other info from mytable .....

Alan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top