Have a checkbox on a form. "UltraCheckEditor"
It can be bound to datasource via Checked , CheckedValue or CheckState.
I chose "Checked".
Want to run an SQL query "before update".
I chose _BeforeCheckStateChanged but _ValidateCheckState may be good too.
Problem is that all these events seem to fire when loading the form and when changing records.
If I could find a way to determine change (e.g. like when comparing .text to .value) then I could make it all work in _BeforeCheckStateChanged.
How do I do this?
The query only really wants to be run when the box is checked by the user and not run for uncheck or systems events.
Please help!!!
Hi,
Sorry, it looks like the editors don't have an event manager. Most of the WinForms controls do, but I guess the editor controls like UltraTextEditor were deemed too simple for an EventManager to be needed.
Anyway, you could achieve the same thing by simply unhooking the event handler (unless you are using VB and you hooked the event at design-time.
Or, you could simply use a flag to bail out of the event.
How to associate UltraCheckEditor with EventManager?
I do not see any property on UltraCheckEditor control which would have name or type remotly resembling EventManager ....
I am using version 9.2.
Thanks.
In _ValidateCheckState it is simple enough to be able to test too.
Console.WriteLine(e.NewCheckState.ToString().Equals("Checked"));
UltraCheckEditor tt = (UltraCheckEditor)sender;
Console.WriteLine(tt.Checked); //false
Console.WriteLine(tt.CheckedValue); //false
Console.WriteLine(tt.CheckState); //unchecked
But having the code in _BeforeCheckStateChanged is better because you can messagebox the user and if they select NO or CANCEL you can then call e.Cancel = true.
_ValidateCheckState does nto have e.Cancel. So is more limited to being an information popup messagebox only.
The focus way will work - so i will use that, thanks.
Since you don't have control over when the binding manager sets the value, you can't trap for setting of the control's value programmatically. You could, however, ensure that the control does not have the input focus before doing something that will trigger a change in the current record, and only running your query then:
Example:private void ultraCheckEditor_CheckedChanged(object sender, EventArgs e){ UltraCheckEditor checkEditor = sender as UltraCheckEditor; if ( checkEditor.Focused ) { // TODO: Run query }}
The UltraCheckEditor doesn't have reveal any way to know why it's value is changing, only that it is.
But it seems to me that if the value changes as a result of anything other than a user action, you should be able to trap this. For example, you could trap whenever you set the value of the control in code and use the UltraCheckEditor's EventManager to disable the event handler during that period.