[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.drawing

Number of characters in textbox line

Aditi Chimbalkar

12/7/2004 12:07:00 PM


Hi,

I am using richtextbox for an application. I am working with c#.

Is there a way to find how many characters can fit in a textbox
line?

One way that I had thought was -
richtextbox1.Size.Width/richtextbox1.Font.Size;
But this does not seem to work. Please help me out.

Thanks and Regards,
Aditi.


2 Answers

Bob Powell

12/7/2004 2:04:00 PM

0

If you're using a monospace font like Courier New you can use the method you
suggest to get a very rough idea but if the font is proportional you're out
of luck.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tips...

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/f...

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





"Aditi Chimbalkar" <aditi_chimbalkar@persistent.co.in> wrote in message
news:eYeNsUF3EHA.2192@TK2MSFTNGP14.phx.gbl...
>
> Hi,
>
> I am using richtextbox for an application. I am working with c#.
>
> Is there a way to find how many characters can fit in a textbox
> line?
>
> One way that I had thought was -
> richtextbox1.Size.Width/richtextbox1.Font.Size;
> But this does not seem to work. Please help me out.
>
> Thanks and Regards,
> Aditi.
>
>


Bob Powell

12/7/2004 2:04:00 PM

0

Also remember that font size is a measure of the height of the EM square,
not the width of the letters.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tips...

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/f...

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





"Aditi Chimbalkar" <aditi_chimbalkar@persistent.co.in> wrote in message
news:eYeNsUF3EHA.2192@TK2MSFTNGP14.phx.gbl...
>
> Hi,
>
> I am using richtextbox for an application. I am working with c#.
>
> Is there a way to find how many characters can fit in a textbox
> line?
>
> One way that I had thought was -
> richtextbox1.Size.Width/richtextbox1.Font.Size;
> But this does not seem to work. Please help me out.
>
> Thanks and Regards,
> Aditi.
>
>