Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rich text box rulers AKA Word Style 1

Status
Not open for further replies.

Bchemist

Programmer
Apr 3, 2002
91
0
0
US
I am trying to build a means of puting rulers (or possibly limiting the width) on top and sides of a rich text box, like word, works, word perfect, etc have.

Basically I am building an app that a user types part of a report into a rich text box, and then generates it as a report via Crystal Reports .NET, however it is not uncommon for part of the report to contain a table of formula that is space dependant (ie like the when users post here at tek-tips and don't use the [tt] [/tt] code for their table examples, it gets all messed up and out of line) so when the rich text box is set to a different width than the report is the formulas and tables get all out of line.

I am open to other options, such as using word as an interface, but I can't figure out a way to incorparate it into my app, nor am I sure about the redistributablity of that approach.
 
I don't understand how word wrapping would pose a problem if you were using a string somewhere else. But, why don't you just make the rich text box user resizeable? Allow the user to click and drag its sides and bottom.
 
The Rich Text box is resizeable already, that is part of the problem.

For example say a user has a page something like this.

[tt]
|------------------|
(a + B)
A = -----
(c + d)

[/tt]

but when the report prints it the word wrap end up like this

[tt]
|--------------|
(a + B)
A = -----
(c + d)

[/tt]

then what actually gets printed works like this
[tt]
|--------------|
(a
+ B) A =
-----
(c + d)

[/tt]

obviously that doesn't make anysense to anybody ready the final report. So what I am trying to do is make it so that the end user can either see a ruler and know where the paage ends or that the text will not flow beyond where the page ends.

I have thought about making the RTB max size say 6.5' (assuming 1' margins on both sides of the report) however one of the requirements of the project is to have user definable page setup. So if they want to use 0.5' margins and a 0.5' gutter on the left they can.

Hopefully that is a bit clearer. I was rather tired when I wrote the first post, and didn't include enough info, sorry.
 
I think I understand. Are you saying that you are trying to show the user via the Rich Text Box how much space they will have to print in the Crystal Report?
 
That is correct. The problem comes in that they can adjust that space, and it makes it impossible to preset the size of the rich text box.

So I was thinking I could handle it similar to word by showing a ruler on the top, and on the side so that they would know when they are changing pages as well.
 
Try putting this code in a test project. You will get the idea. I'm not sure, however, how precise this will be, for example, regarding the size of the fonts on the screen compared to their printed versions, or in fact, if the GraphicsUnit.Document at 300 will correctly exactly to a printed inch.

Code:
     Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
        Dim g As Graphics = e.Graphics
        g.PageUnit = GraphicsUnit.Document
        g.DrawLine(Pens.Black, 0, 150, 2550, 150)
        Dim i As Integer
        For i = 0 To 17
            If i Mod 2 = 0 Then
                g.DrawLine(Pens.Black, (i * 150), 75, (i * 150), 225)
                g.DrawString((i / 2).ToString, Me.Font, Brushes.Black, (i * 150), 250)
            Else
                g.DrawLine(Pens.Black, (i * 150), 100, (i * 150), 200)
            End If
        Next
        g.Dispose()
    End Sub
 
This is a good idea. I will have to play with it a little and see how it corresponds to the printed document, but it is by far the best idea I have come across yet. Thanks

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top