I have a ToolStripButton as a sender within a click event. I need to be able to typecast the sender as a Toolstripbutton and retrieve its tag property as an integer. I think, I am doing that in the following code. My program compiles successfully, but it raises invalid typecast run-time error.
theTool := TMakerTool((sender as ToolStripButton).tag);
TMakerTool = public enum
theTool:TMakerTool
I see that the tag property is an object that contains the tag as a string.
So, what am I doing wrong?
Thank you.
I try to follow Dr. Wily's Apprentice's answer, but it didn't work. However, he did help me understand it better.
If anyone interested, I was able to get the error to go away by doing the following.
theTool := TMakerTool(int32.Parse((sender as ToolStripButton).tag.ToString));