Home All Groups Group Topic Archive Search About

Auto Expanding TextBox/Controls

Author
30 Nov 2004 11:51 PM
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
Author
1 Dec 2004 9:52 PM
Tobin Harris
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
Show quoteHide quote
"Tobin Harris" <tobin@tobin_do_not_spam_harris.com> wrote in message
news:41ad07e8$0$1059$db0fefd9@news.zen.co.uk...
> 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
>
>

Bookmark and Share