how to disable accelerator key for captions?

kirez used Ask the Experts™

hi experts,
      i have a problem i thought i can solve it in a minute, but seems i was wrong. i need to put a label(also menu item) that will show current folder. Everything was ok, until i brosed a folder named 'c:\a&b', here label.caption instead of displaying right folder it displays c:\ab (with b underlined). ANyone knows how can i avoid this? thanks.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

You have to search/replace all '&' characters with '&&' in the string. Something like:

procedure TForm1.Button1Click(Sender: TObject);
var s: string;
  s := 'a&bcde&fgh';
  Label1.Caption := StringReplace(s,'&','&&',[rfReplaceAll]);

Regards, Geo

...or set the ShowAccelChar property to false.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial