SelectedIndexChanged вызывает дважды во время отладки, но только один раз, когда я запускаю его напрямую - C# [закрыто] ⇐ C#
-
Anonymous
SelectedIndexChanged вызывает дважды во время отладки, но только один раз, когда я запускаю его напрямую - C# [закрыто]
I have a ComboBox with the SelectedIndexChanged Event Handler that is firing twice back-to-back while I'm debugging it and other events/functions, but when I run it without debugging, it only fires once (which is what it's supposed to do). Other than the processing waste, I wouldn't mind, but I'm actually triggering the Event directly, otherwise it doesn't call at all when I run it and once when I debug.
The steps go like this: I have a couple KeyEvents monitoring when I press Shift+Enter. When I do, it adds ComboBox.Text to ComboBox.Items and sets ComboBox.DroppedDown to true.
if (e.KeyCode == Keys.Enter) if (ShiftPressed)//This is falsified in KeyUp. { IngredientEnter.Items.Add(IngredientEnter.Text); IngredientEnter.DroppedDown = true; //I manually call the handler because it would call when I would debug, but not when I would just run it. IngredientEnter_SelectedIndexChanged(sender, EventArgs.Empty); } Again, when I'm debugging, SelectedIndexChanged is triggered; when I'm running w/o debugging, it doesn't.
I sincerely apologize if this is a dup, but I looked forever and even created an account just to ask. Edit: Sorry, for the lack of code, hopefully this helps.
Источник: https://stackoverflow.com/questions/780 ... n-i-run-it
I have a ComboBox with the SelectedIndexChanged Event Handler that is firing twice back-to-back while I'm debugging it and other events/functions, but when I run it without debugging, it only fires once (which is what it's supposed to do). Other than the processing waste, I wouldn't mind, but I'm actually triggering the Event directly, otherwise it doesn't call at all when I run it and once when I debug.
The steps go like this: I have a couple KeyEvents monitoring when I press Shift+Enter. When I do, it adds ComboBox.Text to ComboBox.Items and sets ComboBox.DroppedDown to true.
if (e.KeyCode == Keys.Enter) if (ShiftPressed)//This is falsified in KeyUp. { IngredientEnter.Items.Add(IngredientEnter.Text); IngredientEnter.DroppedDown = true; //I manually call the handler because it would call when I would debug, but not when I would just run it. IngredientEnter_SelectedIndexChanged(sender, EventArgs.Empty); } Again, when I'm debugging, SelectedIndexChanged is triggered; when I'm running w/o debugging, it doesn't.
I sincerely apologize if this is a dup, but I looked forever and even created an account just to ask. Edit: Sorry, for the lack of code, hopefully this helps.
Источник: https://stackoverflow.com/questions/780 ... n-i-run-it
Мобильная версия