Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 16th, 2003, 11:00 PM
Registered User
 
Join Date: Oct 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to RighteousManUP
Default 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

 
Old October 17th, 2003, 12:25 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Cross-post. Please see http://p2p.wrox.com/topic.asp?TOPIC_ID=5395 for replies.

Would you mind *not* posting the same message in multiple forums? Your message will be read anyway.....


Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.