vendredi 8 mai 2015

Why does the RadioButton's Click events fire before CheckedChanged?

In my .NET application's GUI (done in C#, but I don't think that matters) are TextBoxes and RadioButtons handling user changeable data.

For the TextBoxes, I handle the KeyDown and the TextChanged event. During the initial setting of the TextBoxes' Text, of course the TextChanged event fires, but since there was no KeyDown event first, the data is not changed by the user (so it does not have to be written back to the store).

Now I wanted to use the same technique for the RadioButtons using the Click or MouseClick event as a user interaction detector. Unfortunately both Click events fire before the CheckedChanged event.

This - IMHO - is just wrong. The Checked property cannot change before the control is clicked. Is this a logical error or does this happen for a reason? Is there any way to force correct behaviour?

(To solve the GUI problem, of course I could just introduce a variable for initial setting of the Control's values. But this is about understanding the logic here.)

Aucun commentaire:

Enregistrer un commentaire