• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 155
  • Last Modified:

format text by Keys - vb.net 2003

Hi Experts,

I wish to write a word processing application which will format text if a specific key is pressed. The document will be RTF based.

Example: If 'CTRL' and letter 'C' is pressed, then left margin to 4.1" ...and if ENTER key is pressed = vbCrLf down to next line & to normal left Margin  2.7"

Is this easy? as I have played around with text boxes and not really got anywhere.

1 Solution
Bob LearnedCommented:
Do you know about these actions with the RichTextBox?

            rtb.SelectionAlignment = HorizontalAlignment.Center
            rtb.SelectionHangingIndent = 200
            rtb.SelectionIndent = 100

RobertoFreemanoAuthor Commented:
Thanks Bob,

I completed my code with:
Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
        Select Case keyData
            Case Keys.Control Keys.C
          RichTextBox1.SelectionAlignment = HorizontalAlignment.Center
            RichTextBox1.SelectionHangingIndent = 200
            RichTextBox1.SelectionIndent = 100
        End Select
    End Function

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now