Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
Hi
I need Help
I Flipped Text like a mirror image.
 
But line brake are not coming, all text from textbox showed in one line
Put Text in text box, while mine is come from database.
 
Here is my code....HELP please
 
Imports System.Drawing.Drawing2D
Imports System.Drawing
 

Public Class Form1
 

    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
 

        ' Draw the text and the surrounding rectangle START.
        Dim text1 As String = RichTextBox1.Text
        Dim font1 As New Font("Arial", 10, FontStyle.Bold, GraphicsUnit.Point)
        Try
            Dim rect1 As New Rectangle(10, 10, 1000, 140)
 
            ' Create a StringFormat object with the each line of text, and the block 
            ' of text centered on the page. 
            Dim stringFormat As New StringFormat()
            stringFormat.Alignment = StringAlignment.Center
            stringFormat.LineAlignment = StringAlignment.Center
 

            ' Draw the text and the surrounding rectangle.
            e.Graphics.DrawString(text1, font1, Brushes.Blue, rect1, stringFormat)
            e.Graphics.DrawRectangle(Pens.Black, rect1)
 
        Finally
            font1.Dispose()
        End Try
        ' Draw the text and the surrounding rectangle END.

 
        '' FLIP TEXT ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        ' Draw Flipped Text the text surrounding rectangle START.

        Using the_font As New Font("Arial", 20, FontStyle.Bold, GraphicsUnit.Point)
 
            DrawFlippedText(e.Graphics, the_font, Brushes.Black, 10, 10, RichTextBox1.Text, True, False)
 
            Dim txt_size As SizeF
            txt_size = e.Graphics.MeasureString(RichTextBox1.Text, the_font)
            e.Graphics.DrawRectangle(Pens.Red, 10, 10, txt_size.Width, txt_size.Height)
 
        End Using
 
        ' Draw Flipped Text the text surrounding rectangle END.
        '' FLIP TEXT ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    End Sub
 
    Public Sub DrawFlippedText(ByVal gr As Graphics, ByVal the_font As Font, ByVal the_brush As Brush, ByVal x As Integer, ByVal y As Integer, ByVal txt As String, ByVal flip_x As Boolean, ByVal flip_y As Boolean)
 
        ' Save the current graphics state.
        Dim state As GraphicsState = gr.Save()
 
        ' Set up the transformation.
        Dim scale_x As Integer = IIf(flip_x, -1, 1)
        Dim scale_y As Integer = IIf(flip_y, -1, 1)
        gr.ResetTransform()
        gr.ScaleTransform(scale_x, scale_y)
 

        ' Figure out where to draw.
        Dim txt_size As SizeF = gr.MeasureString(txt, the_font)
 
        If flip_x Then x = -x - RichTextBox1.Size.Width
        If flip_y Then y = -y - RichTextBox1.Size.Height
 

        ' Draw.
        gr.DrawString(txt, the_font, the_brush, x, y)
 
        ' Restore the original graphics state.
        gr.Restore(state)
 
    End Sub
 
End Class
 

Posted 23-Feb-13 18:44pm
Comments
e9net at 24-Feb-13 23:59pm
   
no problem with your code.
i have replace control RichtextBox1 with TextBox1 (multiline = true)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 235
1 Sergey Alexandrovich Kryukov 144
2 Rob Philpott 100
3 Peter Leow 70
4 CHill60 70
0 OriginalGriff 6,902
1 Sergey Alexandrovich Kryukov 5,623
2 Maciej Los 3,479
3 Peter Leow 3,373
4 DamithSL 2,505


Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 24 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100