I have a grid that lists records and below that a detail of the record displayed. The grid and the detail are linked to the same datasource. This detail has combo boxes displaying the values corresponding to the values in the grid.
What is the best way to detect that a USER has selected a DIFFERENT value from the combo list? I can't use TextChanged() or ValueChanged() because these events get fired by simply scrolling through records in the grid. The regular WinForm combo box has events, SelectedItemChanged() and SelectedValueChanged() in addition to TextChanged() and ValueChanged() but I don't see anything comparable for the UltraCombo. So far, I have resorted to using CloseUp() but this does not necessarily mean a different value was changed by the user.
Basically, I need to activate a "Save" button on my detail if the user changes any value on the form.
Thanks,
--Mark
Hi Mark,
What kind of DataSource are you binding to? If you are using a DataSet/DataTable, then there is build-in support on those objects to track changes and you could enable your save button based on whether there are any pending changes.
Another option is for you to trap the ValueChanged event of the Combo and simply compare the combo's current Value with the Value of the underlying field in the data source.
If using a dataset as datasource, you can check the HasChanges()
If using custom object, you have to implement your own HasChanges() by setting a internal flag when a property changed
OK...I tried what you suggested. I changed the setting for one of my combo boxes to OnPropertyChanged. I ran my application and selected a different item from the combo box. Immediately after that, I click a button on my form that has some dummy code that allows me to set a break point. I inspect the following...
dsLiabilityBindingSource.CurrencyManager.Current => Row => RowState
... and it says "Unchanged". (dsLiability.HasChanges() = false)
Next, in my grid, I navigate to the record below and then back to the record I just modified and click the button again and the property now says "Modified".
Wrong!
If your databinding is set to OnValidation, you have to leave the control (causing validation) to push value into datasource. Other solution, is set the databinding update mode to OnPropertyChanged instead of validation.
Setting is localize into Advances option into property grid for your control
Not really...the underlying dataset does not detect/reflect that by simply selecting a different value in the combo list...you have to either move to a different record or call WriteValue on the binding for it to update the underlying dataset.
But thanks anyhow...