Release Notes for 1.3.23 states that “Wisej.Web.UserComboBox allows the application to use any control as the drop down panel”. Thinking the
DataGridView is a good candidate to be a DropDownControl, I did try how this new control works by dropping 1 UserComboBox and 1 DataGridView
in a window/form and these are what I’ve observed.
ListBox, CheckedListBox, ListView as a DropDownControl seem to display correctly but nothing happens if I mouse-click an item to select it. Looking at the Properties window to find what Event I have to subscribed to, they are basically the same as the standard ComboBox. Can you give a tip how?
Am I using the control the right way or missing something not so obvious?
Got the issues. There are a bunch. In your sample code you set Visible to false otherwise the DGV is also displayed in the form because you add it to the form’s control collection. The UserComboBox removes the drop down control from the collection, but it does it when it’s created. Which is before the Load event fires. If you change the code like this it works:
this.Load += delegate (object sender, EventArgs e)
ucGLCodesDGV ucGLCodesDGV = new ucGLCodesDGV();
ucGLCodesDGV.Size = new System.Drawing.Size(500, 320);
// ucGLCodesDGV.Location = new System.Drawing.Point(497, 92);
// ucGLCodesDGV.Visible = true;
userComboBoxAtRuntime.DropDownControl = ucGLCodesDGV;
The Tab and Enter key are a different problem. The wrapper handles those keys to automatically close the drop down.
Anyway, there are a number of fixes and enhancements that are needed when dropping down a composite panel rather than a list or treeview. The fixes are simple and will most likely be included in the current dev build.
Thanks for the code. But here is what I want to achieved relating to issued #4 in my original post.
I have an existing UserControl (ucGLCodes) with a DGV in it. It is used to display list of GL Accounts for CRUD operations. Following principle of reusability and DRY, instead of dropping a new DGV into the form that uses the UserComboBox control, I would just like to use that same UserControl as a DropDownControl. It displays the UserControl with the right width if I assign it to the DropDownControl property at design time but I can’t make it to display when I am creating an instance of the UserControl from code. And it will only clutter the design surface of the form/window.
Is it by design not to assign a DropDownControl at runtime?
Also, from the attached sample and using at design time, if I press Tab to transfer control from “Column” to “Value” combobox in the UserControl, the dropdown closes automatically. Is there a way it can be prevented from closing?
You are using it right. The problem with the DGV is that the popup menu and the popup panel are both popups – we have to adjust the z-index.
Will also log an enhancement to use the max between the Width of the control used in the drop down and the combobox.
About closing the drop down, it has to be handled by your code since the drop down panel may contain anything it cannot be closed automatically on a click. It can be a treeview or a panel with child controls, etc. See the built-in TreeViewComboBox and ListViewComboBox. I have attched the source code from Wisej for those two since they are built on top of the UserComboBox.
The best way to use the UserComboBox in my view is to create a subclass and manage everything in there. This way you can expose the properties that you need to redirect to the drop down child. The base is the ComboBox because it allows your class to use the base class properties (Items, for example, which can be data bound) to populate your custom drop down panel. Otherwise you can hide those.