PDA

Click to See Complete Forum and Search --> : R/Textbox - Indent - any suggestions?


Dougster
Nov 11th, 1999, 06:42 PM
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

Mimo
Nov 11th, 1999, 06:56 PM
Hi!
Try:
SendKeys() function
It may work...


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

Joacim Andersson
Nov 11th, 1999, 07:18 PM
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
joacim@programmer.net
joacim@yellowblazer.com
www.YellowBlazer.com (http://www.YellowBlazer.com)

Dougster
Nov 12th, 1999, 01:49 AM
Cheers Joacim, thats been a great help!

Many Thanks