473,606 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1411
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******** ********@TK2MSF TNGP11.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.c om/group/microsoft.publi c.dotnet.langua ges.vb/browse_thread/thread/34ec19dee644b0d b>

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******** *****@TK2MSFTNG P11.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******** ********@TK2MSF TNGP11.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.TaskMMDetail s '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.Draw String(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.c om> wrote in message
news:11******** *************@u 72g2000cwu.goog legroups.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.c om/group/microsoft.publi c.dotnet.langua ges.vb/browse_thread/thread/34ec19dee644b0d b>

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.DrawS tring' 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=textboxdisp layedlines&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.n et> 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******** ******@TK2MSFTN GP10.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.DrawS tring' 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=textboxdisp layedlines&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
3842
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 modifications along the way to make the interface more Pythonic. For example, all of these functions return an error code (typically just errno passed along, but not always). They all accept as one of their arguments a pointer to someplace to store...
11
5594
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 squarely in the middle of that string will sorta word wrap. so why doesn't it seem to work with !'s? here's a page that demonstrates how !'s don't seem to word wrap: http://www.geocities.com/terra1024/wordwrap.htm here's a page that shows how...
10
2316
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 too. #include "header.h" /* does the wordwrapping */ void fold(char buffer, int len) {
0
1555
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 (cfront.dll from Navision) but the wrapper access to the DLL doesn't work for some of the exported functions?!? To illustrate what I mean, I have created the following small test-case. You simply compile and link it using the cf.h and libload.c (from...
2
5992
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 managed one. I have taken a look at following sample code on how to do this. http://longhorn.msdn.microsoft.com/lhsdk/ndp/vcmg_appendixs amplecode.aspx
5
1194
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 wishes to do some more advanced integration between our application and their existing site, namely using asp-includes to get the menusystem of their external site integrated with our
4
1663
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 = 0 at the end of the routine? or how can i modify it to work in .NET?? Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress IsNumericInput(TextBox1, 2,...
2
1563
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 command-line app, and capture its output. The larger program however, calls the conversion routine many times, and the overhead of starting units for every call made things too slow. I then re-formulated my use of units to open it using popen2, and do
5
4100
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 to wrap the control in the proper control type - which is also a container. At design time I want to be able to turn this : <my:container> <asp:textbox />
0
8009
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7939
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8432
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8078
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5456
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3919
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3964
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2442
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1285
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.