ComboBox CodeSample - Skinable (custom) combobox automatically dropping down on focus
From Visual WebGui Wiki
| This article will have a few sections added to it soon, based on the following article type skeleton: NewCodeSampleTemplate |
Contents |
Overview
An example of how to implement an autodropdown a ComboBox when the control receives focus. Implemented in two ways, as a Skinable (Custom) ComboBox and with a Theme.
The sample application will only work for Visual WebGui version 6.4 and later.
Implementation
Implemented with a Theme
With this method we build a new Theme, DropDownTheme, where we override the .XSLT for the standard ComboBox to get the desired autodropdown effects.
As this particular Theme is implemented here, the ComboBox.CustomStyle property is used to control if we want autodropdown effects or not. Setting it to "AutoDropdown" will activate the effect, all other values will deactivate it.
Implemented as a Theme, a ComboBox is the control type used and it's the same control wheater the autodropdown is active or not. For performance perspective, this is a much more robust implementation, as everything happens client side, with no roundtrips (postbacks) needed to perform it on the client.
Implemented as a Skinable control
With this method we create a new Skinable control, which is simply a custom control, and we add to it's resources a single very simple JavaScript function that, when called, will toggle the dropdown of the ComboBox. Then we register an event handler to the GotFocus event and in that event we call our JavaScript function via InvokeMethodWithId.
This method creates a new ComboBox control type, called DropDownCombobox, which you will have to use on your forms, and is not interchangeable with the standard ComboBox control as you can if you use the Theme method.
This method is less desireable than the Theme method for performance reasons, as there there will be more roundtrips (postbacks) needed to peform the necessary operations.
Demo application
The sample application includes code for Visual Studio versions VS2005, VS2008 and VS2010, as well as code in both C# and VB.NET.

