Datagridview checkboxes lose checks - winforms

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.

Related

Reset a ComboBox

I have a view that contains several ComboBox elements. For some reason old data remains from the previous time the view was opened and I would like to reset the combobox elements in the view every time it is opened. Is there a function that could that for me? I want it to be exactly how it is as if I rendered it the first time with the initial items. Would using setSelectedItem(vItem), setSelectedItemId(vItem), setSelectedKey(sKey), setShowSecondaryValues() help? If so, what do these keywords mean (selectedItem, selectedItemID, selectedKey, secondaryValues)?
Unfortunately you do not provide an example. Normally you bind your UI controls against a model, e.g. JSONModel. In this case the items of your ComboBox controls would be taken from the corresponding model. However, you can use method removeAllItems to achieve the desired behaviour.
UPDATE: Obviously the controls are bound and only the selection should be cleared.
Use setSelectedItem with value null to clear the selection. You could also use the binding to set the selected item automatically by using the selectedKey attribute, see example.

Write conflict on updating form checkbox with multi-table view as recordsouce

I have created a form with a View as recordsource, this view combines 1 table and another view (with 2 tables in it).
When the checkbox is clicked a validation happens in the Access code that checks if the records checkbox may be updated, if this is not the case then the checkbox value should change back to 0/false.
First I tried to do this simply in the click event of the checkbox and then setting the checkbox value = false when it does not validate. This however gives a write conflict. Next I tried it with a Me.Dirty = false in front of it, this also doesn't help (still getting the write conflict). The checkbox.undo gives the same result.
Then I thought to do it in the before update and use a simple cancel=true, this however causes the focus not to change (it keeps the focus on the same record and never moves from it).
The Timestamp is usually what I use to ignore write conflict messages, I included the timestamp of the main table but this doesn't work (probably because the view is multiple-table based).
Some additional info:
The view is created in the SQL server and is linked to Access
The primary keys of the view (so it is editable) are set by executing a CREATE UNIQUE INDEX statement
Any ideas how I can get this to work?
Fixed it by using a button to set the checkbox bound field to checked/unchecked and making the checkbox itself invisible. This seems to work (better).

On clicking the row of a grid, checkboxes of other rows getting unchecked using checkboxselectionmodel in GWT

I have a multiSelectCombobox that uses a grid with checkboxselectionModel. I want checkboxes getting checked on clicking the checkbox, but what is happening here is when i click the row of an unchecked checkbox, that checkbox gets selected while all the other checkboxes that were previously checked get unchecked automatically.
I have seen many threads posted on Sencha but none seem to be of any help.
grid=new Grid(skillsetStore, new ColumnModel(columnConfigs));
cm.setSelectionMode(SelectionMode.MULTI);
grid.setStyleAttribute("borderTop", "none");
grid.setBorders(true);
grid.setStripeRows(true);
grid.setWidth(300);
grid.getView().setForceFit(true);
grid.getView().setAutoFill(true);
grid.setSelectionModel(cm);
grid.addPlugin(cm);
grid.setHideHeaders(true);
This is my grid that i am using...
Any help on this issue would be much appreciated.
I had a similar issue. I was setting the checkbox value to false in data bind complete event. Once I removed it, it worked fine

Additional filtering parameters in #fuelux datagrid

Does the fuelux datagrid support adding additional filter options? I would like - for instance - to add (next to the filter dropdown you already have in place), a checkbox which should also be added as a parameter to my function that retrieves the data remotely from the server.
It would be nice if the grid would automatically take any parameters from input elements that we can mark by adding a specific class or data- attribute.
Thanks very much! :)
David.
You can absolutely do this.
Add filtering logic to the datasource you provide, keyed off any custom property you add to the datasource.
Add the checkbox within the datagrid markup (or anywhere).
When your checkbox is clicked, update the custom property on your datasource and then call $('#MyGrid').datagrid('reload') to tell the datagrid to reread your datasource

Cannot tab out of databound Winforms dropdown list

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.

Resources