Visual Basic Q&A

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries for September, 2010

BUG: TextBox content is not automatically scrolled to display selected text on receiving focus

Symptoms
When you programmatically select the content of a text box, and the selected content resides in the area that you cannot see of the TEXTBOX control, then the text in the text box does not scroll automatically to display the selected text. Also, when you move to the TEXTBOX control by pressing TAB, the selected text does not appear automatically when the text box receives the focus.
Resolution
To work around this problem, you can use the ScrollToCaret method of the TEXTBOX control. This method scrolls the content of the control to the current caret position.
Copy the following code to the textBox1_Enter event:
Visual Basic Code

textBox1.ScrollToCaret()Visual C# Code

textBox1.ScrollToCaret();

BUG: Text Box and Data Control on a UserControl Closes UserControl in the IDE

Symptoms
A Standard EXE or UserControl form contains a second UserControl. The second UserControl contains a text box and a data control. You close all the forms and then open the second UserControl. When you attempt to change the DataSource property of the text box in the property window, the UserControl immediately closes or an application error occurs that causes Visual Basic to stop responding.
Resolution
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.