473,491 Members | 2,008 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Setting ShortCut property for MenuItems

I have a table (about 50 rows that populate the variables shown below in
lines 1 and 2) of shortcuts that I would like to read into a Windows Form.
The following code would work with one big exception:

CType will not convert a string to a MenuItem. (Line 3)

Dim MyShortCut As Integer = 13122 '13122 is integer for Ctrl2
Dim MyMenuItem As String = "MenuItem12"
Dim oMnu As Windows.Forms.MenuItem = CType(MyMenuItem,
Windows.Forms.MenuItem)
Dim oSC As Windows.Forms.Shortcut = CType(MyShortCut,
Windows.Forms.Shortcut)
oMnu.Shortcut = oSC

Is there a way to read and dynamically set this property from a table using
a different approach?
Nov 21 '05 #1
2 1282
genojoe wrote:
I have a table (about 50 rows that populate the variables shown below in
lines 1 and 2) of shortcuts that I would like to read into a Windows Form.
The following code would work with one big exception:

CType will not convert a string to a MenuItem. (Line 3)

Dim MyShortCut As Integer = 13122 '13122 is integer for Ctrl2
Dim MyMenuItem As String = "MenuItem12"
Dim oMnu As Windows.Forms.MenuItem = CType(MyMenuItem,
Windows.Forms.MenuItem)

Try this:

Dim oMnu as New Windows.Forms.MenuItem(MyMenuItem, MyEventHandler,
MyShortcut)

or, set the shortcut after just setting the text.

Tom
Dim oSC As Windows.Forms.Shortcut = CType(MyShortCut,
Windows.Forms.Shortcut)
oMnu.Shortcut = oSC

Is there a way to read and dynamically set this property from a table using
a different approach?

Nov 21 '05 #2
I could not make it work. Thanks for the effort.

"tomb" wrote:

Try this:

Dim oMnu as New Windows.Forms.MenuItem(MyMenuItem, MyEventHandler,
MyShortcut)

or, set the shortcut after just setting the text.

Tom

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
378
by: Luke Wright | last post by:
Hi, I have built a setup project to install an application I am developing. I would like to be able to prompt the user whether to install Shortcuts in the following locations: * Start Menu *...
4
8823
by: Salad | last post by:
A97. If you set a forms properties to ShortcutMenu = No, the entire form is disabled from displaying a shortcut menu. If you set the property to Yes, all controls have a shortcut menu. I have...
0
2739
by: Marcel | last post by:
Hi, the application I am writing has a MainMenu and a DataGrid (UltraGrid). Now I have to edit the text of each cell in this grid. So far so good. All works fine in editmode but if I press a...
15
2313
by: Jeff Mason | last post by:
I have an application where I need to set certain menu items invisible based on a user privilege. We did a sinmlar thing in VB6 and used the menu item's tag property to assign an identifier to...
1
1840
by: Björn Dietz | last post by:
Hello all, I'm just testing the VS2005 beta. I've added a MenuStrip with some MenuItems in it, these I furnished with a "ShortcutKeyDisplayString". I was expecting that when I press that key...
6
3323
by: Charleees | last post by:
Hi all, I have a DropDown and a TextBox just bekeow it... I have to get the selected value from dropdown and set it as textBox Text.. The thing is i have to do this Without PostBack..... ...
3
1519
by: Mike Edgewood | last post by:
Is there a simple way, shortcut, or macro to create a property skeletons? I would live to be able to type a name and a type and have the property created based on that info. Private...
2
1922
by: diego | last post by:
hi everyone, i have a sub that opens a form given the form's name as string and opens it using System.Reflection. How can I set the form's properties at runtime. Here is my code. Public Sub...
12
1529
by: NithyaVijayAnnanth | last post by:
Hi, I am new to vb.net I have a problem with mdiform menuitems enabled property.How to enable or disable the menuitems in mdiform from another form.The condition is that when the mdiform loads all...
0
6978
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7154
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7190
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6858
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5451
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4881
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4578
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3086
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.