Article ID: 168824 - Last Review: August 7, 2007 - Revision: 1.3 FIX: Setting ComboBox Control Text in Click Event Wipes Out TextThis article was previously published under Q168824 On This PageSYMPTOMS
When setting the ComboBox control Text property in the Click event of
ComboBox control, the text always returns blank. This is different behavior
than Visual Basic 3.0 and Visual Basic 4.0.
RESOLUTION
Instead of setting the Text property of the ComboBox control in the Click
event, change it at the LostFocus event by shifting the focus to another
control, such as TextBox, although it leaves the focus set to the
TextBox. To work around that, hide a TextBox behind the ComboBox with
TabStop property set to False. In the GotFocus event of the TextBox, set
the focus back to the ComboBox. To place a TextBox behind the ComboBox in
design time, choose the Send To Back menu command from the Format/Order
menu. In run time, set the z-order of TextBox to 1.
The following code example shows how to keep the text of ComboBox control after being set at the Click event:
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in the latest service pack for Visual Studio 6.0. For additional information about Visual Studio service packs, click the following article numbers to view the articles in the Microsoft Knowledge Base: 194022
(http://support.microsoft.com/kb/194022/EN-US/
)
INFO: Visual Studio 6.0 Service Packs, What, Where, Why To download the latest Visual Studio service pack, visit the following Microsoft Web site:194295 (http://support.microsoft.com/kb/194295/EN-US/ ) HOWTO: Tell That a Visual Studio Service Pack Is Installed http://msdn2.microsoft.com/en-us/vstudio/Aa718353.aspx
(http://msdn2.microsoft.com/en-us/vstudio/Aa718353.aspx)
MORE INFORMATIONSteps to Reproduce Behavior
| Article Translations
|
Back to the top
