Cannot tab out of databound Winforms dropdown list - winforms

This is a bit of a strange one, but I've been struggling for a few hours now and I can't understand what is happening.
I was wondering if anyone else has experienced this problem, and can perhaps explain it. I'm building a simple Winforms app and trying to use many of the built in controls.
Basically, I've got a form with a user control and some data capture fields. 3 of the fields are dropdown lists and on the user control I have a bindingSource control that binds directly to a Product class.
At run time I provide an instance of the Product class to the BindingSource and the class contains a property of ProductType. For simplicity I also added a List<ProductType> ProductTypes to the Product Class which loads itself when queried, which means I can just use the same bindingSource and choose the ProductTypes Data Member as the Datasource for the dropdownlist.
Upon running the form, the list binds perfectly and I can see all the product types listed, and I can select one and tab or click to the next field. But obviously the selected value won't bind because I've not chosen any bindings-SelectedValue for the dropdown, only a datasource. As soon as I make sure that the drop down modifies the instance of the Product by binding to the Bindings-SelectedValue, and then run the form, the list still gets populated perfectly and I can tab through the controls as long as I don't make a selection from the dropdown. If I make a selection from the dropdown then the dropdown holds focus. I cannot tab out for love or money and can't even click cancel button on the form, the close button top right is the only button I can click which works and I can't click any other field or dropdown. This affects all three dropdowns as soon as a selection is made.
Anyone have any ideas what I'm missing?
I have tried changing a few things and had some success by feeding the dropdown values a string[] instead of a member of an object. That seems to work, but defeats the object of using databinding doesn't it?
Any help appreciated!

Just guessing here, because I don't have time to set up a test and confirm right now, but are you doing any validating? I seem to remember that data-bound controls won't let you leave if the contents don't validate. Even if you aren't explicitly, try setting CausesValidation to False to see if there's any sort of validation going on behind the scenes, that might at least give you a hint.

Thanks for the input on this, helped me wrap my head around this.
In my case, it turns out that an exception was being thrown in one of the EventHadlers for my ComboBox.Validating event. It was hard to track down, because the IDE didn't show me that exception. I was able to modify the Exception behavior (in the debug menu) and have it show me any InvalidOperationException that was being thrown, and then I was able to track it down.
As Tom suggested, turning off CuasesValidation was the ticket to figuring it out.

For Infragisticst Dropdowns (may not be true for other winform dropdowns): If you have "LimitToList" set to true you can be stuck in a dropdown that you can't get out of without realizing it. Use the ItemNotInList even to trigger a warning message.

Related

selected item of dropDownSelectTree disappeared when create button in TabbedForm(React admin) change

I am working with react admin and I am using TabbedForm to add data, the problem is that when I select item from dropDownSelectTree, and then add text to TextInput, the create button change from disable to able and my selected itemed disappeared, I want to know how to keep my selected items when the button change.
This could be a lot of things from incorrect state handling to incorrect props setup. However, without the actual code to check not many people will be able to help you out. So if you may, share your code with us.

uib-typeahead dropdown doesn't disappear when focus shifts?

I've got a dropdown in this spreadsheet-like UI which provides a list of names as possible valid entries for the cell. When I tab or return out of the cell, it disappears as it should, but when I click away, to a different cell, the dropdown list isn't dismissed. Any thoughts on how to get that to work? (Theres a lot going on in the code, including ng-keydown and ng-blur directives, too involved to show here, but any pointers what to look for would be appreciated.)
Here are some pictures:
Works properly as I start typing -- but when I click to another cell:
Drop down still remains...
Found the problem, there was an 'event.preventDefault' in the blur event in certain circumstances which is responsible for the box not dismissing.

Datagridview checkboxes lose checks

In my Winforms app, I have a form that contains a datagridview with a checkbox column. If I check one or more checkbox items, then make a change to some other control on the form (outside of the datagridview), the checkboxes become unchecked. Any help would be appreciated. Thanks.
More details: The underlying binding for the checked items is working correctly, as the values are being stored and the checked states are correct when the form reloads. This is just a visual issue.
Furthermore, the checkbox value is never programmatically set to false in the code. False values only come from the binding or from being manually unchecked.
Redesigned the binding and now it works fine. Was previously maintaining a list of selections in the business object and checking checkboxes based on the selections. Now maintaining a "selected" property in the business object and binding appropriately.
Problem manifested as described due to nature of events generated by checkbox editing (apparently). Binding source change event not triggered when clicking the checkbox (since it was not bound) - only occurred after editing complete on another control.
Could you do an "Invalidate()" on the column to see if a redraw changes anything? Without code, we need to divide the problem arbitrarily.

Vaadin: Reload ComboBox List while typing

I got a ComboBox in Vaadin and want to reload (from db) the set of entries in the dropdown list while typing in the text field of the ComboBox. I always got the exception:
java.lang.IllegalStateException: A connector should not be marked as dirty while a response is being written.
I tried to lock the session (getUI().getSession().getLockInstance().lock();), but it didn't help.
Is it possible to dynamically set/load the selection list of a ComboBox?
Cheers
Stefan
why do you want to change the content from DB as the user type? you'll get a postback and a query every key the user presses... isn't better to use the standard combo feature (which tries to autocomplete the value given what the user is typing)?
Anyway, if you really need this feature, you may extend the standard behaviour of combo extending the container behind the combo, as the data shown is taken from a container.

How do I refresh Winforms DataGridView?

I have two DataGridViews in a tab and the DataSource of the second grid is based on the row selection in first grid. The problem is I cannot get the grid to refresh after some values have been inserted or updated in the prior tabs. It works fine if I click on the row but it is not working if I select the row programmatically (i.e. first row). I have tried the following but it failed to refresh.
daProgram.ClearBeforeFill = true
daProgram.fill(dsProgram)
bsProgram.ResetBindings(true) -- binding source also tried false
dgvProgram.DataSource=bsProgram -- rebinding the control
I also tried:
dgvProgram.DataSource=nothing
and
dgvProgram.DataBindings.clear()
Nothing works :-(
I would really appreciate if anyone could help me out in this.
Are you binding your data properly?
http://www.theserverside.net/discussions/thread.tss?thread_id=31014
http://bytes.com/groups/net-c/256204-refresh-databindings-winform
I have read a few things about this, and too found ResetBindings not to work.
If you're using Table Adapters, just call the fill method (the method that auto gets added in to your Form Load event).
I've read things that say you shouldn't call Fill. I see no reason why not. It simply re-queries the data, which is exactly what a refresh should do.
Me.YourTableAdapter.Fill(Me.YourDataSet.YourDataTable)
Try This
dgvProgram.DataSource=null;

Resources