Microsoft KB Archive/820626

= BUG: The KeyUp event of the RichTextBox control is raised two times in Visual Studio .NET and in Visual Studio 2005 =

Article ID: 820626

Article Last Modified on 12/6/2006

-

APPLIES TO


 * Microsoft .NET Framework 1.1
 * Microsoft Visual Basic 2005
 * Microsoft Visual Basic .NET 2003 Standard Edition
 * Microsoft Visual C# .NET 2003 Standard Edition

-



SYMPTOMS
If you use a RichTextBox control that is included with Microsoft Visual Basic 6.0 in your Microsoft Visual Studio .NET 2003 application, the KeyUp event is raised two times.



WORKAROUND
To work around this bug, use the RichTextBox control that is included with Microsoft Visual Studio .NET or Microsoft Visual Studio 2005 instead of using the RichTextBox control that is included with Visual Basic 6.0.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce the Behavior
 Create a new Microsoft Windows application by using Microsoft Visual Basic 2005, Microsoft Visual Basic .NET, or Microsoft Visual C# .NET. On the Project menu, click Add Reference. Click the COM tab, and then click to select Microsoft RichTextBox Control, version 6.0. From the toolbox, drag the Microsoft RichTextBox Control, version 6.0 control to Form1.

The AxRichTextBox1 control is created. In Solution Explorer, right-click Form1, and then click View Code.  Add the following code in the variable declaration section for Form1:

Visual Basic .NET or Visual Basic 2005 Code ' Declare the counter variable. Dim counter As Int32 = 0 Visual C# .NET Code // Declare the counter variable. int counter=0; </li>  Add the following code to the KeyUp event of the AxRichTextBox1 control:

Visual Basic .NET or Visual Basic 2005 Code ' Increase the counter. counter += 1 Console.WriteLine(counter.ToString) Visual C# .NET Code // Increase the counter. counter += 1; Console.WriteLine(counter.ToString); </li> On the Debug menu, click Start to run the application.</li> Press any key in the RichTextBox control.

The counter value in the output window is 2.</li></ol>

Keywords: kbvs2005swept kbvs2005applies kbrichedit kbwindowsforms kbuidesign kbinterop kbctrl kbbug KB820626

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.