In general, it's probably not good design to have a variable width textbox. It could interfere with whatever is to the right of the control or shoot the right hand side of the control off the form. The other problem is dealing with variable width fonts. But, if you must, in this.gotfocus(): this.width = len(this.value)*fontmetric(6,wfont(1),wfont(2)) might do it. However, I would prefer to use an edit box of a fixed width and let longer strings wrap.
Eric Kleeman - EDS Consulting Services
MCP Visual FoxPro
MCSD C#.NET
Hua Hin Thailand
Los Angeles California