473,387 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to suppress Ctrl+i key combination in a RichTextbox?

I've noticed that Ctrl+i creates a Tab, whereas I'd like to make it
italicize instead. My code is as follows

Private Sub txtPrivate_KeyDown(ByVal sender As System.Object, ByVal e
As System.Windows.Forms.KeyEventArgs) Handles txtPrivate.KeyDown
'IF CTRL WAS PRESSED
If e.Control Then
'IF "I" WAS PRESSED TOO
If e.KeyCode = Keys.i Then
If Not txtPrivate.SelectionFont Is Nothing Then
'MAKE SELECTED TEXT ITALIC
If txtPrivate.SelectionFont.Italic Then newFontStyle =
FontStyle.Regular Else newFontStyle = FontStyle.Italic
End If
end if
end if
End Sub

How can I suppress the default event that happens when creating a tab
character, so that my italic will take place only?

Jan 29 '07 #1
5 2841
In article <11*********************@a34g2000cwb.googlegroups. com>,
kw****@gmail.com says...
How can I suppress the default event that happens when creating a tab
character, so that my italic will take place only?
Try letting windows know you handled the keypress by setting e.Handled
to True.

--
Patrick Steele
http://weblogs.asp.net/psteele
Feb 2 '07 #2
It don't work Patrick because I tried that when finding a solution around 1
week ago. I even tried overriding WndProc too, but without success.

--
Newbie Coder
(It's just a name)
Feb 2 '07 #3
In article <e1**************@TK2MSFTNGP05.phx.gbl>,
ne*********@spammeplease.com says...
It don't work Patrick because I tried that when finding a solution around 1
week ago. I even tried overriding WndProc too, but without success.
Are you using .NET 2.0? There's a new property called
"SuppressKeyPress" that I just tested with your code and it works fine.
It prevents the RichTectBox from setting the CTRL+I.

--
Patrick Steele
http://weblogs.asp.net/psteele
Feb 2 '07 #4
No, I am using .NET Framework 1.1 where it doesn't work

I recently formatted my development machine because after VS 2005 SP 1
installed it slowed my machine down & all VS 1.1 projects took 30 secs to
load not 1-2 secs as they should. Now is 100% better

I had Visual Studio 6 Enterprise, Visual Studio.NET 2003 Enterprise
Architect & then VS.NET 2005 Professional. Now just VS.NET 2003 Enterprice
Architect

--
Newbie Coder
(It's just a name)
Feb 2 '07 #5
Same... using .NET Framework 1.1 here too. Are there any other
solutions?

Feb 5 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Greg | last post by:
I want to be able to capture the user pressing Ctrl+S. I know that the IE browser has a key binding for Ctrl+S but is there any way that I can be notified of this key press anyway. I have found...
3
by: Stefan | last post by:
Hy, i have an app and i must disable this combination: ALT+F4; CTRL+ALT+DEL; CTRL+ESC;ALT+TAB like this: i find something on Internet and i can block ALT+F4 protected override...
0
by: Kaki | last post by:
I have a RichTextBox with AcceptsTab set to true. When Ctrl is held down, pressing Tab does not trigger KeyPress or KeyDown/Up events. If AcceptsTab is false, the RichTextBox never knows if Tab...
9
by: Miky | last post by:
Hi, I need to send Ctrl-PgUp (or Ctrl-PgDown) to the active application but when I use SendKeys.Send("^{PGUP}"), the program understands it as just PageUp. How may I solve it? Thanks in...
0
by: B Loggins | last post by:
Hi everyone, thanks in advance fo any help on this issue. I'm trying to "wrap" cmd.exe. That is, I'm redirecting StandardInput and StandardOutput for a cmd.exe process and I'm sending StdOut to...
0
by: positivebalance | last post by:
..net 2.0 richtextbox autodragdrop how to make the control respond to Ctrl key for move copy? it's handy to have the enableautodragdrop is true but two odd things I notice: 1. when I first...
0
by: Gouri.Mahajan7 | last post by:
Hello, I have hosted the windows user control (which has one richtextbox) on web page. When I type the keys such as Ctrl+O on it the open window pops up and the control (i.e. richtextbox) is not...
1
by: Andrus | last post by:
I need to detect Ctrl+MouseWheel press in WinForms RichTextBox control to save changed font size. In protected override void OnMouseWheel(MouseEventArgs e) MouseEventArgs does not allow to...
1
by: Andrus | last post by:
I need to save font selected by user by Ctrl+MouseWheel in Winforms RichTextBox. I tried override below but this does not remember font: in this method Font.Size property seems to be always...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.