Thankyou Dave. I will look at that. But I can't help thinking i've
asked the wrong question.
Perhaps I'll try again maybe someone can offer a solution.
My textbox takes text data from the user and then copies this to the
clipboard. I then switch to another application and paste this data
from the clipboard into the other application. The application
receiving the text demands that the text cover no more than 5 lines,
each line consisting of no more than 75 characters.
The reason I was trying to resize the textbox was so that it looked the
same as it would look when it is pasted into this second programme.
But I realise now I need some way of enforcing that each line contains
only 75 characters, because even if I managed to size the textbox
exactly to 5x75 character lines, there is nothing stopping the user
from actually entering 1x375 line into this textbox. If i can find a
way of enoforcing that each line in the textbox has a maximum size of
75 characters I think this in itself will take care of the text being
displayed as it will look in the target application once it is pasted.
Any idea how I do this with the standard multiline textbox?
I was considering just creating 5 seperate text box, and playing around
with their events to try to make them act as one text box, do you think
this will be a better approach?
Thankyou Experts,
Gary.
Dave Sexton wrote:
Hi Gary,
You can get an approximation using the Graphics.MeasureString method (GDI+)
or TextRenderer.MeasureText method (GDI; 2.0 framework only). Simply call
CreateGraphics on the TextBox and pass the Graphics object to one of the
Measure* methods along with the specific text and Font.
If the Font isn't fixed-width then you should probably specify 375 upper
case "M" characters as the text to ensure maximum coverage for the
calculation. Otherwise, 375 of any printable character will do for a
fixed-width font.
Note: Don't be tempted to draw to the Graphics object retrieved from the
CreateGraphics method and don't forget to dispose of it after the text is
measured.
--
Dave Sexton
http://davesexton.com/blog
<ga********@myway.comwrote in message
news:11*********************@11g2000cwr.googlegrou ps.com...
I have a multiline textbox.
The size of the text box should be 75 characters wide, and 5 lines in
height like this: -
<---75 characters-->
<---75 characters-->
<---75 characters-->
<---75 characters-->
<---75 characters-->
I have used maxlength to limit the characters to 375 (75 X 5).
My question is how to I specify the layout of the textbox to be 75
characters wide and 5 lines in height. The only size property i can see
takes a value in pixels, which isn't suitable here.
Thankyou,
Gary.