[Mono-bugs] [Bug 78912][Nor] New - Cannot modify KeyChar in a KeyPress event handler

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Thu Jul 20 13:45:34 EDT 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by kuba.brecka at gmail.com.

http://bugzilla.ximian.com/show_bug.cgi?id=78912

--- shadow/78912	2006-07-20 13:45:34.000000000 -0400
+++ shadow/78912.tmp.31371	2006-07-20 13:45:34.000000000 -0400
@@ -0,0 +1,51 @@
+Bug#: 78912
+Product: Mono: Class Libraries
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: Unknown
+Priority: Normal
+Component: Windows.Forms
+AssignedTo: peter at novonyx.com                            
+ReportedBy: kuba.brecka at gmail.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Cannot modify KeyChar in a KeyPress event handler
+
+When I add a KeyPress event handler to a TextBox, and when I modify the
+KeyPressEventArgs.KeyChar value, it has no effect.
+
+Reproduce code:
+using System;
+using System.Windows.Forms;
+
+namespace MonoTest18
+{
+    class Form1 : Form
+    {
+        static void Main()
+        {
+            Application.Run(new Form1());
+        }
+
+        public Form1()
+        {
+            TextBox T = new TextBox();
+            T.Location = new System.Drawing.Point(10, 10);
+            T.KeyPress += new KeyPressEventHandler(T_KeyPress);
+            Controls.Add(T);
+        }
+
+        private void T_KeyPress(object sender, KeyPressEventArgs e)
+        {
+            e.KeyChar = 'A';
+        }
+    }
+}
+
+When you type anything into the TextBox, it should replace every character
+with capital A (which it doesn't do).


More information about the mono-bugs mailing list