Auto Expanding TextBox/Controls

  • Thread starter Thread starter Tobin Harris
  • Start date Start date
T

Tobin Harris

Hi there,

I've googled this problem, and not found a suitable solution yet. I was
wondering if anyone has made any progress?

Basically, I want to make a textbox automagically adjust it's height to show
all the text it contains. So, if I add text then it grows, and it shrinks if
I remove text. This is similar to the CanGrow property in MS Access
controls.

I'm willing to purchase a control if anyone knows of any, I'd just like to
get this cracked without spending *too* much time "fiddling" about!

Any help much appreciated

Tobin
 
I found it! It took *lots* of searching, but it's quite straight forward...

public static int GetLineCount( TextBoxBase textbox )

{

const int EM_GETLINECOUNT = 186;

return SendMessage( textbox.Handle, EM_GETLINECOUNT, 0, 0 );

}

Handles word wrap too!

Tobin
 
Back
Top