Get localized string from System.Windows.Forms.Shortcut

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The System.Windows.Forms.Shortcut enum has all values for MenuItem shortcuts.
Is it possible to get the localized string of such a shortcut?

I tried myShortCut.ToString() but this returns a value like "CtrlP". I would
like to have "Strg+P" on a German Windows.

Thanks for any ideas,
Guido
 
Thanks for your idea. Unfortunately KeysConverter.ConvertToString(myShortCut)
seems to ignore the current culture. It returns "CtrlP" and not "StrgP"
(German).

Of course, I could localize shortcuts myself (replacing "Ctrl" by "Strg" and
so on) but I'm wondering if there is a .NET framework built-in way of doing
this. I need the localized shortcut for owner-drawing MenuItems.

Thanks,
Guido
 
Guido Kraus said:
The System.Windows.Forms.Shortcut enum has all values
for MenuItem shortcuts.
Is it possible to get the localized string of such a shortcut?

\\\
Imports System.ComponentModel
Imports System.Windows.Forms
..
..
..
Dim sc As Shortcut
For Each sc In [Enum].GetValues(GetType(Shortcut))
Me.ComboBox1.Items.Add( _
TypeDescriptor.GetConverter( _
GetType(Keys) _
).ConvertToString(CType(sc, Keys)) _
)
Next sc
///
 
The method shown is intrinsically the same method they use in the Windows Forms
classes to draw the shortcut on the menu. The only change I've made is to call
KeysConverter directly in place of TypeConverter.GetConverter(typeof(Keys)).
The GetConverter method just reads does caching and attribute based look-up
to retrieve the KeysConverter in a more round-about way.

ConvertToString in turn uses CultureInfo.CurrentCulture... Which in turn calls
Thread.CurrentThread.CurrentCulture... Are you certain the culture is being set
up correctly before making your conversions? Does turning off the owner drawn
menu'ing and using the default Windows Forms menu'ing show the correct thing?

Lots of different possibilities.
 
Hi Guido,

In your application, what is the value of
Thread.CurrentThread.CurrentCulture? Also, in your system's menu items,
what is the text of "Ctrl+P"? Is it "Strg+P"?

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi Guido,

Have you viewed my reply? Does my reply make sense to you?

Please feel free to tell me, I will work with you. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
To get the display string "Strg+P" on a German Windows it is necessary to
change the CurrentUICulture AND to install the .NET Framework German Language
Pack! Otherwise you will get "Ctrl+P" though the CurrentUICulture is set to
"de".

Best regards,
Dirk Ströker
 
Back
Top