Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ColumnWidths Property in Combobox acting strange?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
ColumnWidths Property in Combobox acting strange?
Miscellaneous
Thread ID:
00407894
Message ID:
00407894
Views:
60
Cetin Basoz was so kind as to send me some code that automatically calculates the ColumnWidths of a combobox. It appears to calculate the ColumnWidth correctly for any number of columns. But the only problem I am having is that when I click on the combobox it doesn't give me the full ColumnWidths value that this code calculated. This code came up with a value of 176 for a max value which appears to be correct. After I select an item from the drop-down list the next time I click on the combobox it widens to match the size of the last item that I clicked on. Then, if I click and select a third item (say it's the longest row in the drop-down list, then it widens to 176 its full width. Why doesn't it widen to full width initially?

Here is the code that Cetin Basoz sent me:
I was going to ask Cetin, but he has probably retired for the day.
Any ideas?
With thisform
  Select last_name, first_name, emp_id from employee into array .myArray
  For ix = 1 to alen(.myArray,2)
    Store 0 to ('lnColWidth'+padl(ix,3,'0'))
  Endfor
  lcFont = .Fontname
  lnFontSize = .Fontsize
  For ix=1 to alen(.myArray,1)
    For jx = 1 to alen(.myArray,2)
      Store ;
        max(eval('lnColWidth'+padl(jx,3,'0')),;
        txtwidth(trim(.myArray[ix,jx]),lcFont,lnFontSize)*fontmetric(6,lcFont,lnFontSize)) ;
        to ('lnColWidth'+padl(jx,3,'0'))
    Endfor
  Endfor
  lcColumnWidths = ''
  For ix = 1 to alen(.myArray,2)
    lcColumnWidths = lcColumnWidths + iif(empty(lcColumnWidths),'',',')+;
      ltrim(str(eval('lnColWidth'+padl(ix,3,'0'))))
  Endfor
  .Combo1.Columncount = alen(.myArray,2)
  .Combo1.ColumnWidths = lcColumnWidths
Endwith
Steve Kramer
Kramer & Kramer Design
"Home of Go Cartoons"
Web Site: www.stephenkramer.com
Would you believe Far Side Lite?
More than 270 original cartoons.
Reply
Map
View

Click here to load this message in the networking platform