 |
|
 |
There is a bug that binding the DatagridView ,set "gridview.datasoure=DataTable " and PopControl doesnt show the data!
no
|
|
|
|
 |
|
|
 |
|
 |
First,Thank you for your Excellent work.
When i trigged the MsgBox message(vb.net),I found the code excuted the WndProc function which is in the CustomCombobox class repeatedly and I couldn't close the MsgBox window, no matter Ok or Cancel button that I clicked.Please help me to solve this trouble,thanks!
|
|
|
|
 |
|
 |
Hi,
I am glad that you found my article of interest!
Would you be able to provide an example of the problem that you are experiencing with some instructions that describe how I can reproduce the problem. I will then take a look into your specific problem.
I am familiar with VB.NET as well as C#, so it doesn't bother me which you use.
Many thanks,
Lea Hayes
|
|
|
|
 |
|
 |
Hi,
great piece of code!
One improvement: at design time, the "Snap lines" are missing. Here is an enhancement to the "CustomComboBoxDesigner" which adds at least the purple line used to align other controls in the some "row":
internal class CustomComboBoxDesigner : ParentControlDesigner
{
protected override void PreFilterProperties(IDictionary properties)
{
...
}
public override IList SnapLines
{
get
{
IList snaplines = base.SnapLines;
SnapLine snapBaseLine = new SnapLine(SnapLineType.Baseline, 15);
snaplines.Add(snapBaseLine);
return snaplines;
}
}
}
I found that the Baseline for default comboboxes is at 15 pixel. Of course this does not work for non-default font sizes, but it is a good start .
Wolfgang
|
|
|
|
 |
|
 |
Hi,
Thanks, I am glad that this has been of use!
I hadn't implemented any of the designer specific features because they were beyond the scope of the project that I was working on. Thank you for providing a code example for "Snap lines". I will try and include it in the next version.
Thanks again!
Lea Hayes
|
|
|
|
 |
|
 |
Thanks for your code - very cool
My suggestion is to use the inherited DroppedDown property instead of the custom IsDroppedDown to minimize behavioral/interface changes to the inherited ComboBox. I have implemented this in my code, and so far it seems to work. Originally I attempted to set DroppedDown to false expecting it to work. Is there a reason I missed as to why you did not override DroppedDown?
Here is how I implemented DroppedDown:
[Browsable(false), Description("Gets or sets a value indicating whether the combo box is displaying its drop-down portion.")]
public new bool DroppedDown
{
get { return m_bDroppedDown; }
set
{
if (value)
ShowDropDown();
else
HideDropDown();
}
}
In addition, I made ShowDropDown and HideDropDown private and non-virtual, deleted the IsDroppedDown property and changed IPopupControlHost as follows:
public interface IPopupControlHost
{
#region Properties
bool DroppedDown { get; set; }
#endregion
}
Born to code.
|
|
|
|
 |
|
 |
Thank you for your kind words!
Without having an understanding of the underlying .NET code, I wanted to avoid causing problems elsewhere. I cannot remember if I tried overriding that property or not, it has been quite a while since I originally wrote this code.
I know that I explicitly reference the base.DroppedDown property within another function in that class to hide the original standard drop down, but despite this, I think there were some scenarios where the drop down was appearing above the custom drop down.
If overriding the DroppedDown property isn't causing any problems then I totally agree, this is a much neater approach. If this is the case, then personally I think that the ShowDropDown and HideDropDown functions should be protected and virtual to allow for specialized extensions.
Many thanks,
Lea Hayes
|
|
|
|
 |
|
 |
I create a numeric panel usercontrol, I want to ask how to get caller - combobox.text? Thanks
example: this.parent.text But,it's wrong. What should I?
|
|
|
|
 |
|
 |
The simplest way is to access the combobox control with its identifier. For example:
String text = myComboBox.Text;
Or, you could make some simple changes to your user control:
public class NumericPanel : UserControl
{
... YOUR STUFF ...
public ComboBox OwnerDropDown { get; set; }
public void testFunction()
{
if (OwnerDropDown != null)
{
String text = OwnerDropDown.Text;
}
}
}
And then add the following line to your construction code:
...
NumericPanel numericPanel = new NumericPanel();
numericPanel.OwnerDropDown = myComboBox;
...
Let me know how you get on!
Lea Hayes
|
|
|
|
 |
|
 |
Hi!
First I want to thank you for your work. It's a really nice and helpful control.
I just started programming in C#. Now I have a question:
There is no property to set the control read-only. If there is a chance to do so, would you please explain it?
Thank you very much!
siggi
modified on Wednesday, September 9, 2009 2:12 AM
|
|
|
|
 |
|
 |
Try adding the following property into the "CustomComboBox" class, this should solve your problem.
The "DropDownStyle" attribute was only removed because the "Simple" mode is not compatible. Thanks for the feature suggestion, it will be included in the next update.
[Category("Custom Drop-Down")]
public bool ReadOnly
{
get { return base.DropDownStyle == ComboBoxStyle.DropDown; }
set { base.DropDownStyle = value ? ComboBoxStyle.DropDownList : ComboBoxStyle.DropDown; }
}
Let me know how you get on.
Lea Hayes
|
|
|
|
 |
|
 |
Thinking about it, in read-only mode the control will probably not show any text because the "DropDownList" feature requires the original drop-down.
Adding one item to the list would solve this problem, but would cause two drop-downs to appear (one on top of the other).
Again, let me know how you get on.
|
|
|
|
 |
|
 |
Nice Work.
It would be nice if your resizable dropdown honored MinimumSize.
As it stands, the constraint is enforced, but your resize logic doesn't realize it.
Another useful feature would be the ability to add buttons to the resize bar at the bottom of the drop down, to have modal behavior (e.g., cancel and close, or accept and close).
|
|
|
|
 |
|
 |
Thank you very much for your suggestions.
I will try to incorporate the "MinimumSize" logic into the next update.
I am not sure about the idea of having a modal drop down because that is not the kind of behaviour a user would generally expect from a drop down control. In situations where a modal interface is required I would generally recommend using a dialog box perhaps with an ellipsis button: [TEXT BOX ][...]
Thanks again!
Lea Hayes
|
|
|
|
 |
|
 |
In IE8, look at the search box drop down, for an example
of what I was referring by buttons (not necessarily modal
behavior).
|
|
|
|
 |
|
 |
How i implement the dropdowncontrol within listview control. Add coloumns, items, subitems
|
|
|
|
 |
|
 |
Dear All,
Can somebody tell me is it possible to enter some value into combobox, when dropdown form is loaded.
I should do this if I want to simulate autocomplete function.
The only way I found till now is to catch keydown event from popup form and to enter catched value into combobox.
If you open simple combobox in form you can see cursor and to write into combo when dropdown is open.
Thanks!
|
|
|
|
 |
|
 |
I do not understand what you are asking.
You can handle the KeyDown event whilst the user is typing in the actual combo box control. You can also handle the DropDown event which fires then the drop down form is shown, and then DropDownClosed is fired then the drop down form is hidden.
If you want to be able to type into the drop down form (and influence the combo control) then you will need to manually implement this into your specialized drop-down form.
I hope that this is of help, let me know if you have any further questions.
Many thanks,
Lea Hayes
|
|
|
|
 |
|
 |
Hi - I'm trying to use your control with a TreeView, and much like a regular combobox I need to hide the dropdown when a node is selected. However calling HideDropDown() in my event handler causes the parent form to lose focus. Any way around this? Thx!
|
|
|
|
 |
|
 |
Perhaps something like the following would work?
myTreeCombo.HideDropDown();
myTreeCombo.Parent.Focus();
Let me know how you get on!
Many thanks,
Lea Hayes
|
|
|
|
 |
|
 |
I tried various combinations without success... Here's the general idea:
private TreeView treeView1 = null;
private void Form1_Load(object sender, EventArgs e)
{
treeView1 = new TreeView();
treeView1.Nodes.Add("Node 1");
treeView1.Nodes.Add("Node 2");
treeView1.AfterSelect += new TreeViewEventHandler(treeView1_AfterSelect);
customComboBox1.DropDownSizeMode = CustomComboBox.CustomComboBox.SizeMode.UseDropDownSize;
customComboBox1.DropDownControl = treeView1;
}
void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
customComboBox1.HideDropDown(); }
|
|
|
|
 |
|
 |
Try the following, perhaps the re-focusing is being done too soon:
private TreeView treeView1 = null;
private Timer timerAutoFocus = null;
private void Form1_Load(object sender, EventArgs e)
{
treeView1 = new TreeView();
treeView1.Nodes.Add("Node 1");
treeView1.Nodes.Add("Node 2");
treeView1.AfterSelect += new TreeViewEventHandler(treeView1_AfterSelect);
customComboBox1.DropDownSizeMode = CustomComboBox.CustomComboBox.SizeMode.UseDropDownSize;
customComboBox1.DropDownControl = treeView1;
}
private void timerAutoFocus_Tick(object sender, EventArgs e)
{
if (!this.Focused)
{
this.Focus();
timerAutoFocus.Enabled = false;
}
}
void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
customComboBox1.HideDropDown();
if (timerAutoFocus == null)
{
timerAutoFocus = new Timer();
timerAutoFocus.Interval = 10;
timerAutoFocus.Tick += new EventHandler(timerAutoFocus_Tick);
timerAutoFocus.Enabled = true;
}
}
I am unable to test the above code at this point, but I am pretty sure that something like this should do the trick.
Give it a try and let me know if it does the trick!
|
|
|
|
 |
|
 |
Much better, thanks!
Only minor change is put timerAutoFocus.Enabled = true; outside the last if statement otherwise it only works once.
|
|
|
|
 |
|
 |
Excellent, I am glad that worked for you.
Well spotted, yeah that statement should have been beneath the if statement.
|
|
|
|
 |