473,405 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Is there a wrapping routine in the .NET Framework??

Siv
Hi,
I am trying to find a wrapping routine for text and not having much luck.
The reason I need one is that I am producing a report where the text that
was stored in the database was written into a multi-line text box, so it
contains long strings of text where the user allowed the wrapping of the
text box to wrap the text within its confines and here and there, they will
have entered CRLFs where they have pressed ENTER to push in a break between
paragraphs. This has always caused me problems when writing this stuff out
to a report as I have a certain width on the printed page and usually a
certain amount of depth. There must be a .NET framework function that can
process a piece of text and insert the relevant breaks that doesn't split
words and constrains it within a given rectangle that you specify.

Can anyone help me as I can't find anything??
--
Siv
Martley, Near Worcester, United Kingdom.
Apr 1 '06 #1
9 1398
Siv,

You don't get word for free, but what you ask looks for me the most at the
RichTextBox.

http://msdn.microsoft.com/library/de...classtopic.asp

I hope this helps,

Cor

"Siv" <dotnet@remove_me.sivill.com> schreef in bericht
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,
I am trying to find a wrapping routine for text and not having much luck.
The reason I need one is that I am producing a report where the text that
was stored in the database was written into a multi-line text box, so it
contains long strings of text where the user allowed the wrapping of the
text box to wrap the text within its confines and here and there, they
will have entered CRLFs where they have pressed ENTER to push in a break
between paragraphs. This has always caused me problems when writing this
stuff out to a report as I have a certain width on the printed page and
usually a certain amount of depth. There must be a .NET framework
function that can process a piece of text and insert the relevant breaks
that doesn't split words and constrains it within a given rectangle that
you specify.

Can anyone help me as I can't find anything??
--
Siv
Martley, Near Worcester, United Kingdom.

Apr 1 '06 #2
Hi Siv,
There must be a .NET framework function that can
process a piece of text and insert the relevant breaks that doesn't split
words and constrains it within a given rectangle that you specify.


No, there is no such pre-built function in .NET. You're going have to
code for such a functionality.

This thread asks a question that, I believe, is related to what you
want to do. Check it out and see if it helps,

<http://groups.google.com/group/microsoft.public.dotnet.languages.vb/browse_thread/thread/34ec19dee644b0db>

Regards,

Cerebrus.

Apr 1 '06 #3
Siv
Cor,

I think you may have misunderstood what I am after. I am writing a report
that the user can priny out. The data that I am trying to display in the
report is made up of long strings of text. I then have to write that out to
a printed report but I have to fit it into a rectangular box on that report
that has a certain width and depth.

My problem comes in trying to get that text wrapped to fit the report layout
without losing any of the text or breaking words up as well as honouring any
carriage returns that were entered in the original piece of text.

As a lot of controls like the rich text box and the multi-line text box
intelligently wrap text as you type, there must be a routine (presumably
part of the Dot Net Framwork) that these controls use and I was hopeful I
could use that in my printing routine.

I have tried to roll my own and got a fairly good routine but it seems a bit
sluggish and it sometimes gets confused stuck in an iterative loop that I
haven't been able to fix yet, due to deadlines I decided I would see if
there was a built in function that does the same job, returning the text
formatted with line breaks that allow it to fit on the report within the
specified widths.
--
Siv
Martley, Near Worcester, United Kingdom.
"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:Ov*************@TK2MSFTNGP11.phx.gbl...
Siv,

You don't get word for free, but what you ask looks for me the most at the
RichTextBox.

http://msdn.microsoft.com/library/de...classtopic.asp

I hope this helps,

Cor

"Siv" <dotnet@remove_me.sivill.com> schreef in bericht
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,
I am trying to find a wrapping routine for text and not having much luck.
The reason I need one is that I am producing a report where the text that
was stored in the database was written into a multi-line text box, so it
contains long strings of text where the user allowed the wrapping of the
text box to wrap the text within its confines and here and there, they
will have entered CRLFs where they have pressed ENTER to push in a break
between paragraphs. This has always caused me problems when writing this
stuff out to a report as I have a certain width on the printed page and
usually a certain amount of depth. There must be a .NET framework
function that can process a piece of text and insert the relevant breaks
that doesn't split words and constrains it within a given rectangle that
you specify.

Can anyone help me as I can't find anything??
--
Siv
Martley, Near Worcester, United Kingdom.


Apr 1 '06 #4
Siv
Cerebrus,

I am pleased to say that you are wrong (I don't mean that in a nasty way),
after hunting around furiously in the MSDN documentation I found the
answer!! Hurrah. The routine I currently use to output the text actually
does it, I just hadn't looked at the overloaded versions of the drawstring
method.

The code that does the magic is:

Dim rect As System.Drawing.RectangleF
Dim str as String

Str = sp.TaskMMDetails 'A piece of text from a class with lots of text
in it with breaks etc.
rect.X = LM + 100 'LM is a var holding my left margin so my
rectangle
rect.Y = y + (n * 100) 'y is a var tracking where I am down the
document incremented by lineheight
rect.Width = LM + 650 'width of my reports rectangle
rect.Height = 100 'Height of my reports rectangle

'Then write it out
e.Graphics.DrawString(Str, fb, Brushes.Black, rect)

The text is output to the report and is wrapped within the rectangle
specified by rect, it works brilliantly.

Additionally there is an additional parameter which deals with string
fromatting which I haven't unravelled yet that allows you to do stuff like
centre align right align etc also there are switches that allow you to
determine whether you want the text that would be cut off by the bottom of
the rectangle to appear or not and also whether it would insrt an elipsis at
the botytom right corner of the rectangle followed by the last word in the
text.

BRILLIANT! Cheers MS it was right under my nose all the time. Teach me to
explore all the overloaded versions.

For anyone interested the article that led me to this on MSDN is as follows:
http://msdn.microsoft.com/library/de...ntwinforms.asp

Thanks to Cor for putting me in the MSDN library which prompted me to look a
bit harder and find the answer there.
Thanks to Cerberus for responding, I was getting a bit despondent as a
couple of my questions here earlier seemed to be sitting unanswered.
--
Siv
Martley, Near Worcester, United Kingdom.

"Cerebrus" <zo*****@sify.com> wrote in message
news:11*********************@u72g2000cwu.googlegro ups.com...
Hi Siv,
There must be a .NET framework function that can
process a piece of text and insert the relevant breaks that doesn't
split
words and constrains it within a given rectangle that you specify.


No, there is no such pre-built function in .NET. You're going have to
code for such a functionality.

This thread asks a question that, I believe, is related to what you
want to do. Check it out and see if it helps,

<http://groups.google.com/group/microsoft.public.dotnet.languages.vb/browse_thread/thread/34ec19dee644b0db>

Regards,

Cerebrus.

Apr 1 '06 #5
Siv wrote:
BRILLIANT! Cheers MS it was right under my nose all the time. Teach me to
explore all the overloaded versions.


I've noticed that the documentation in MSDN for VS 2005 is vastly
improved for this sort of thing wrt what came before.

:-)

Yeah, MS, that was a compliment! It's good to see a steady improvement
and the new docs now lack only an index into fundamentals documents. Or
the fundamentals documents themselves.

Dr. Gui ought to return with a screaming ten-million-dollar-a-year
vengeance, until the core technologies of the 2.0 Framework are fully
explained.

Rob
Apr 1 '06 #6
"Siv" <dotnet@remove_me.sivill.com> schrieb:
I am trying to find a wrapping routine for text and not having much luck.
The reason I need one is that I am producing a report where the text that
was stored in the database was written into a multi-line text box, so it
contains long strings of text where the user allowed the wrapping of the
text box to wrap the text within its confines and here and there, they
will have entered CRLFs where they have pressed ENTER to push in a break
between paragraphs. This has always caused me problems when writing this
stuff out to a report as I have a certain width on the printed page and
usually a certain amount of depth. There must be a .NET framework
function that can process a piece of text and insert the relevant breaks
that doesn't split words and constrains it within a given rectangle that
you specify.


Check out the overloads of 'Graphics.DrawString' if you want to draw text
with word wrapping turned on.

Additional topics:

Determining the lines as they are being displayed in a textbox control
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=textboxdisplayedlines&lang=en>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Apr 1 '06 #7
Siv
Rob,

I must confess to being a bit useless with search help, I can search for
hours and not find what I want and other people just seem to instinctively
know what to enter in the search engine to get what they want. It was the
same in exams as a kid, all the kids would read the question and get the
correct meaning, I would read it and assume it was a lot more complicated
than it was. I think my brain must be in backwards?
--
Siv
Martley, Near Worcester, United Kingdom.

"Rob Perkins" <rp******@usa.net> wrote in message
news:49************@individual.net...
Siv wrote:
BRILLIANT! Cheers MS it was right under my nose all the time. Teach me
to explore all the overloaded versions.


I've noticed that the documentation in MSDN for VS 2005 is vastly improved
for this sort of thing wrt what came before.

:-)

Yeah, MS, that was a compliment! It's good to see a steady improvement and
the new docs now lack only an index into fundamentals documents. Or the
fundamentals documents themselves.

Dr. Gui ought to return with a screaming ten-million-dollar-a-year
vengeance, until the core technologies of the 2.0 Framework are fully
explained.

Rob

Apr 1 '06 #8
Siv
Herfried,
Thanks, I already found this myself if you check out the other replies to
this question, but thanks anyway as I might not have.

--
Siv
Martley, Near Worcester, United Kingdom.

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:uT**************@TK2MSFTNGP10.phx.gbl...
"Siv" <dotnet@remove_me.sivill.com> schrieb:
I am trying to find a wrapping routine for text and not having much luck.
The reason I need one is that I am producing a report where the text that
was stored in the database was written into a multi-line text box, so it
contains long strings of text where the user allowed the wrapping of the
text box to wrap the text within its confines and here and there, they
will have entered CRLFs where they have pressed ENTER to push in a break
between paragraphs. This has always caused me problems when writing this
stuff out to a report as I have a certain width on the printed page and
usually a certain amount of depth. There must be a .NET framework
function that can process a piece of text and insert the relevant breaks
that doesn't split words and constrains it within a given rectangle that
you specify.


Check out the overloads of 'Graphics.DrawString' if you want to draw text
with word wrapping turned on.

Additional topics:

Determining the lines as they are being displayed in a textbox control
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=textboxdisplayedlines&lang=en>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Apr 2 '06 #9
Hi Siv,
I am pleased to say that you are wrong (I don't mean that in a nasty way),
after hunting around furiously in the MSDN documentation I found the
answer!!


Thank you very much for that correction. I was thinking in a linear
fashion only(String class members only). A good reminder to me, to
expand my horizon and to "Never say die!".

I'm very glad you found the answer. I will keep it in mind, in case I
need it in the future.

Regards,

Cerebrus.

Apr 2 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Roy Smith | last post by:
I've got a C library with about 50 calls in it that I want to wrap in Python. I know I could use some tool like SWIG, but that will give me a too-literal translation; I want to make some...
11
by: yawnmoth | last post by:
word wrapping normally treats some spaces as line feeds, if there hasn't been a line feed for quite a while. so while a string with eighty consecutive a's might not word wrap, a space placed...
10
by: Douglas G | last post by:
I've tried various ideas on this problem, but I don't see word wrapping. Can you point out what is wrong? It's a K&R exercise, and I'm still new to programming. Other pointers would be helpful...
0
by: Alfred B. Thordarson | last post by:
I have unsuccessfully searched back and forth for a solution to the following problem. I hope someone out there can help me. I have created a C++ .NET wrapper for a 3-rd party C based DLL...
2
by: Paul Kenny | last post by:
Hi, I am trying to expose the functionality of an unmanaged C++ class to the other languages available in the .NET Framework. I have decided to do this by wrapping the unmanaged C++ class in a...
5
by: Michael Dyremo | last post by:
Hello. We have a web-application built in ASP.NET using WebForms and Remoting. When selling this application we always incorporate it into the customers existing web-site. Our latest customer...
4
by: Craig G | last post by:
i have a small routine which i used in VB6 to check whether or not a field is off numeric input but im having a problem when trying to change this over to .NET what do i use instead of KeyAscii...
2
by: TheSeeker | last post by:
Hi, As part of a larger project, I am trying to use the GNU Units program to provide unit conversions between quantities. My first iteration, which worked OK, was to simply use units as a...
5
by: gerry | last post by:
I am trying to create a custom container control that will only ever contain a specific type of control. At design time, when a control of a different type is added to the container I would like...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.