473,698 Members | 2,156 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_KeyD own(ByVal sender As System.Object, ByVal e
As System.Windows. Forms.KeyEventA rgs) Handles txtPrivate.KeyD own
'IF CTRL WAS PRESSED
If e.Control Then
'IF "I" WAS PRESSED TOO
If e.KeyCode = Keys.i Then
If Not txtPrivate.Sele ctionFont Is Nothing Then
'MAKE SELECTED TEXT ITALIC
If txtPrivate.Sele ctionFont.Itali c Then newFontStyle =
FontStyle.Regul ar Else newFontStyle = FontStyle.Itali c
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 2889
In article <11************ *********@a34g2 000cwb.googlegr oups.com>,
kw****@gmail.co m 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*********@spa mmeplease.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
"SuppressKeyPre ss" 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
4965
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 tons of examples of capturing keys in IE but *none* of them work for capturing Ctrl+S, Ctrl+F, Ctrl+P,etc or any key combination that has a binding in IE. Does anyone know how to do this?
3
44005
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 System.Boolean ProcessCmdKey(ref System.Windows.Forms.Message msg,System.Windows.Forms.Keys keyData)
0
1479
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 or Shift + Tab is pressed. btw, KeyPreview does not help either... Anyone has an idea?
9
3021
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 advance, LDV-ME.
0
3918
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 a RichTextBox where I'm doing stuff to the text. I'm also passing the characters typed to the RichTextBox to StandardInput for cmd.exe. This is all working quite well, but the problem is that I cannot get cmd.exe to process Ctrl-C correctly. ...
0
1303
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 use the control it gives a no dragdrop allowed cursur effect but on second dragdrop it works ok forevermore until I change the e.drageffect.copy to e.drageffect.move or vice versa. always seems to need some initialization but this is not...
0
1160
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 receiving that character. Same with some other shortcut keys such as Ctrl+P, Ctrl+A and so on. Can anybody please give me the solution for it.?? The control should receive such characters when typed on it on web page. Thanks in advance.
1
1592
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 dedect Ctrl key holding. How to discover in OnMouseWheel event that Ctrl key is hold down when mouse wheel is rotated ?
1
4919
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 *initial* Font size when RichTextBox is created, *not* the font size set by ctrl+mouse wheel. How to find the font size set by Ctrl+Mouse wheel ?
0
8674
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8603
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9157
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8895
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7725
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4369
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2329
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.