Hi,
I am trying to resolve the following scenario:
We have a text box of fixed width that by default should display only 1 line
of text without a scrollbar indicator.
If there are multiple lines of text then we need to to indicate that by
displaying a button alongside the textbox that the user can click on to
expand the height of the text box. The height would be, say, 4 lines of
text. If there are more than 4 lines of text then we need to display a
vertical scrollbar.
To be able to achieve this, it seems, we need to be able to compare the
length of the text with that of the textbox. If we can somehow get the
length in pixels that would solve part of the problem?
Any ideas would be greatly appreciated...
Thanks, VishalInstead of trying to accomplish this by pixels (the hard way), try this:
A textbox that does not have any styling applied to it will use a font where
different characters are different widths (capital W is wider than lower
case l). So, pick a number of characters that you consider to be one full
line of text. You can programmatically check the number of characters in a
textbox and when you reach your one line limit, you can change the rows
property of the textbox to 4. The vertical scroll bar is built in, so you
don't have to worry about enabling it when needed.
"Vishal Gupta" <vishalg_99@.hotmail.com> wrote in message
news:eqX6Zmr3DHA.2112@.TK2MSFTNGP10.phx.gbl...
> Hi,
> I am trying to resolve the following scenario:
> We have a text box of fixed width that by default should display only 1
line
> of text without a scrollbar indicator.
> If there are multiple lines of text then we need to to indicate that by
> displaying a button alongside the textbox that the user can click on to
> expand the height of the text box. The height would be, say, 4 lines of
> text. If there are more than 4 lines of text then we need to display a
> vertical scrollbar.
> To be able to achieve this, it seems, we need to be able to compare the
> length of the text with that of the textbox. If we can somehow get the
> length in pixels that would solve part of the problem?
> Any ideas would be greatly appreciated...
> Thanks, Vishal
Check out the .NET Framework Class Library for:
Graphics.MeasureString Method (String, Font)
"Scott M." <s-mar@.BADSPAMsnet.net> wrote in message
news:%233OjMrr3DHA.3656@.TK2MSFTNGP11.phx.gbl...
> Instead of trying to accomplish this by pixels (the hard way), try this:
> A textbox that does not have any styling applied to it will use a font
where
> different characters are different widths (capital W is wider than lower
> case l). So, pick a number of characters that you consider to be one full
> line of text. You can programmatically check the number of characters in
a
> textbox and when you reach your one line limit, you can change the rows
> property of the textbox to 4. The vertical scroll bar is built in, so you
> don't have to worry about enabling it when needed.
>
> "Vishal Gupta" <vishalg_99@.hotmail.com> wrote in message
> news:eqX6Zmr3DHA.2112@.TK2MSFTNGP10.phx.gbl...
> > Hi,
> > I am trying to resolve the following scenario:
> > We have a text box of fixed width that by default should display only 1
> line
> > of text without a scrollbar indicator.
> > If there are multiple lines of text then we need to to indicate that by
> > displaying a button alongside the textbox that the user can click on to
> > expand the height of the text box. The height would be, say, 4 lines of
> > text. If there are more than 4 lines of text then we need to display a
> > vertical scrollbar.
> > To be able to achieve this, it seems, we need to be able to compare the
> > length of the text with that of the textbox. If we can somehow get the
> > length in pixels that would solve part of the problem?
> > Any ideas would be greatly appreciated...
> > Thanks, Vishal
0 comments:
Post a Comment