![]() |
| ||
| Problem with simple ComboBox With this code: Imports System.TextCreate a default Windows Form Project with a default ComboBox and default Button in the default Form. Double-click the Form to open the code window, replace everything there with the above code. Run the code in the debugger – menu item Debug/Start Debugging . Close the spurious MsgBox. Left click once in the ComboBox, press the <a> key (any valid file name character will do); left click the button. Note the two MsgBox messages report that no item was selected in the ComboBox (button click) and that nothing was entered into the asteriskReplacement StringBuilder (you may uncomment the “Timing” MsgBox in WhichChar() to verify that it is not entered). Note that in each message string I have wrapped the variable with a leading and trailing underscore so that null string variables look like __ <two underscores together> and a string containing a single space looks like _ _ <underscore><space><underscore>. The problem is that when I enter a value via the keyboard (even adding a carriage return) the ComboBox does not enter the _SelectedIndexChanged() function. It does enter the _Leave() function (when I click the button), but note that by the time _Leave() is entered the .SelectedIndex value is no longer valid. I have spent many hours trying to figure this out; it is obviously a very basic concept and everyone else uses this gadget with ease. I have no idea where I am going wrong. Any help would be greatly appreciated! |
| ||
| Re: Problem with simple ComboBox A ComboBox, as it's name implies is a combination of a TextBox and a ListControl. If you type an 'a' into the "TextBox" you will see that the ComboBox.Text property contains an 'a'. To put that 'a' into the dropdownlist you have to do a ComboBox1.Items.Add or .Insert |
| ||
| Re: Problem with simple ComboBox Quote:
What other tool would do this job? |
| ||
| Re: Problem with simple ComboBox I think you need to check out the DropDownStyle property. Set it to DropDownList. |
| ||
| Re: Problem with simple ComboBox The SelectedIndexchanged() event only fires when you actually click an item to "change" the contents of the combobox.... perhaps "click" or "keypress" would be the right choice? |
| All times are GMT -4. The time now is 5:25 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC