Results 1 to 4 of 4

Thread: R/Textbox - Indent - any suggestions?

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 1999
    Posts
    5

    Post

    Hi,

    I am working on a project that involves a richtextbox.

    I am currently setting up shortcut keys to activate the bold, italic and underline typefaces. I know how to do, and have succeeded with ctrl-u and ctrl-b, but with ctrl-i, it not only selects Italic, it also inserts a tab. I guess this is a default shortcut key in the rtb.

    Can anyone tell me how to disable this? I suppose one way would be to assimilate a backspace press, after the italics have been set, but this is not ideal.

    Many Thanks

  2. #2
    Addicted Member
    Join Date
    Nov 1999
    Location
    Lost
    Posts
    216

    Post

    Hi!
    Try:
    SendKeys() function
    It may work...


    ------------------

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Post

    The reason the rtbBox inserts a tab when you press CTRL+I is because CTRL+I equals ASCII value 9 which is a tab character. To avoid this use the KeyDown event and set the KeyCode value to 0 (zero).

    Private Sub RichTextBox1_KeyDown(KeyCode As Integer, Shift As Integer)
    If (Shift And vbCtrlMask) = vbCtrlMask Then
    Select Case KeyCode
    Case vbKeyI
    'set the KeyCode to 0 so the rtfBox doesn't insert a tab
    KeyCode = 0
    RichTextBox1.SelItalic = Not RichTextBox1.SelItalic
    Case vbKeyB
    RichTextBox1.SelBold = Not RichTextBox1.SelBold
    Case vbKeyU
    RichTextBox1.SelUnderline = Not RichTextBox1.SelUnderline
    End Select
    End If
    End Sub

    Good luck!

    ------------------
    Joacim Andersson
    [email protected]
    [email protected]
    www.YellowBlazer.com



  4. #4

    Thread Starter
    New Member
    Join Date
    Oct 1999
    Posts
    5

    Post

    Cheers Joacim, thats been a great help!

    Many Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width