Results 1 to 4 of 4

Thread: Keyboard Event Problems

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2009
    Posts
    78

    Keyboard Event Problems

    Hi, I'm making a text editor. I found that control-i automatically adds some sort of space block into the textbox by default; like how control-z undoes even if I don't code. I want to use control-i for making italics text; but the spaces are interfereing. It's one big block of spaces. Anyone know how I can fix this?

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: Keyboard Event Problems

    it's an indent. couldn't you use a different key combination? Alt+i or something?

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: Keyboard Event Problems

    ok. i investigated. it seems to insert a tab. here's a workaround:

    vb Code:
    1. Public Class Form1
    2.  
    3.     Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
    4.         If e.Modifiers = Keys.Control AndAlso e.KeyCode = Keys.I Then
    5.             RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, FontStyle.Italic)
    6.             e.SuppressKeyPress = True
    7.         End If
    8.     End Sub
    9.  
    10.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    11.         Me.KeyPreview = True
    12.     End Sub
    13.  
    14. End Class

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Dec 2009
    Posts
    78

    Re: Keyboard Event Problems

    K ty, e.surpresskeypress prevents the auto action

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