in my Main Tab,I have some controls, in my first control I have a Combobox. I wrote an SelectionChange for MainTab , but it also fires when it accoured in combobox,I hadnt add any selection change event to my combobox, but when I add selection change to Combobox an开发者_如何转开发d set e.erouted=true , the maintab selection changed will not be fired. what Can I do to prevent firing maintab selectionchange when I change another control selected item ?
In the Main tab selection change event
if (e.OriginalSource.GetType() != typeof(ComboBox))
{
//do the code of main tab selection here..
}
I have hit this problem as well, and have not yet found the cause or correct solution. My current (albeit simple) workaround for this is to check that the sender is the object you are expecting.
In this case it would mean something like this:
if (sender != MainTab)
return;
Setting e.Handled to true will stop the event from bubbling up from child control (ComboBox) to the parent control (TabControl)
精彩评论