We help IT Professionals succeed at work.
Get Started

Problem with converting from ToolStripMenuItem to Button in C#

VooDooBamboo asked
Last Modified: 2012-05-06
I am VERY new to C# coming from VB and having an issue.  I have some code that had some options within a toolstipmenu.  I removed these and replaced them with buttons on the form instead.  Below is the code for one of them.  I just took the code and copied it for the button but its not working.  

It dies on....
ToolStripMenuItem item = (ToolStripMenuItem)sender;

Unable to cast object of type 'System.Windows.Forms.Button' to type 'System.Windows.Forms.ToolStripMenuItem'.

I know its because there is no more toolstripmenu.  As I said I replaced the options on that with buttons.  Any ideas on what is wrong?

Thank you
private void button14_Click(object sender, EventArgs e)
            CurrentSeat.Enabled = true;
            ToolStripMenuItem item = (ToolStripMenuItem)sender;
            LastSeat = (KeyValuePair<LLUUID, LLVector3>)item.Tag;
            Client.Self.RequestSit(LastSeat.Key, LastSeat.Value);

Open in new window

Watch Question
High School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Top Expert 2009
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE