ToolbarButton toggling
The code will compile, but when I run it, the debugger throws an exception claiming invalid cast exception for the, "int button in," part of the foreach loop. If I do toolBar1.Buttons[1].Pushed = true; as a test, the code has no problem setting the second button to toggled on. The goal of this foreach loop is to turn all the buttons to a non-toggled state, then it will set the button that was clicked to a toggled state. I need to do this in order to keep a mutually exclusive setting for the buttons which represent draw modes. So what is going on?
foreach (int button in toolBar1.Buttons)
{
toolBar1.Buttons[button].Pushed = false;
}
toolBar1.Buttons[ButtonClicked].Pushed = true;
Thanks,
Jon
|