tags:

views:

27

answers:

1

I am trying to get the text of a ToolStripMenuItem as if it has been rendered for drawing.

If I have this:

var ts = new ToolStripMenuItem("&New File...");

I want to get "New File...", and there does not seem to be a property to get this information.

I had a look through the TextRenderer and ToolStripRenderer classes in Reflector, and eventually found that it passes the string to an unmanaged function that renders the text to a graphics object.

Does any one know of a built in way of getting the rendered string, or should i just roll my own that handles the & (and && etc)?

A: 

Are you asking how to remove the '&' characters? Can't you just do something like:

ts.Text.Replace("&", string.Empty);
msergeant
Pondidum