Dynamically adding menu items and their OnClick events

How do I add items to a menu while simultanesously adding an OnClick event 
for each.  I have an 2Xn array of text items (labels) and matching URLs.e.g.

"Google", www.google.com
"Yahoo", www.yahoo.com

I want the first column to be the menu label and the second column is where 
the browser goes when the menu is clicked.  OK, so the first part is easy.

AdditionalToolStripMenu.DropDownItems.Add(strResearchLinksArray(i, 1))

How do I go to strResearchLinksArray(i, 0) when that item is clicked.  I am 
vb.net 2005.
-- 
Thanx & Regards,
Anil Gupte


0
Anil
3/2/2010 4:38:13 PM
dotnet.languages.vb 830 articles. 0 followers. Follow

3 Replies
1014 Views

Similar Articles

[PageSpeed] 13

Am 02.03.2010 17:38, schrieb Anil Gupte/iCinema.com:
> How do I add items to a menu while simultanesously adding an OnClick event 
> for each.  I have an 2Xn array of text items (labels) and matching URLs.e.g.
> 
> "Google", www.google.com
> "Yahoo", www.yahoo.com
> 
> I want the first column to be the menu label and the second column is where 
> the browser goes when the menu is clicked.  OK, so the first part is easy.
> 
> AdditionalToolStripMenu.DropDownItems.Add(strResearchLinksArray(i, 1))
> 
> How do I go to strResearchLinksArray(i, 0) when that item is clicked.  I am 
> vb.net 2005.

  dim item = AdditionalToolStripMenu.DropDownItems.Add(strResearchLinksArray(i, 1))
  item.tag = i

In the click event:

  Dim index = DirectCast(DirectCast(sender, ToolStripItem).Tag, Integer)
  dim address = strResearchLinksArray(index, 0)


- or -

Create a class inheriting from ToolStripMenuItem and add a property "ServerName".



-- 
Armin
0
Armin
3/2/2010 5:11:51 PM
Sorry, I have been unable to connect for a while.  Thanx for your help.

I am not sure I understand your solution.  You said "in the  click event" 
and you have me add a line.  My question is, how does one add or assign a 
click event to each item in the array?

-- 
Thanx & Regards,
Anil Gupte
"Armin Zingler" <az.nospam@freenet.de> wrote in message 
news:%235pL30iuKHA.4908@TK2MSFTNGP06.phx.gbl...
> Am 02.03.2010 17:38, schrieb Anil Gupte/iCinema.com:
>> How do I add items to a menu while simultanesously adding an OnClick 
>> event
>> for each.  I have an 2Xn array of text items (labels) and matching 
>> URLs.e.g.
>>
>> "Google", www.google.com
>> "Yahoo", www.yahoo.com
>>
>> I want the first column to be the menu label and the second column is 
>> where
>> the browser goes when the menu is clicked.  OK, so the first part is 
>> easy.
>>
>> AdditionalToolStripMenu.DropDownItems.Add(strResearchLinksArray(i, 1))
>>
>> How do I go to strResearchLinksArray(i, 0) when that item is clicked.  I 
>> am
>> vb.net 2005.
>
>  dim item = 
> AdditionalToolStripMenu.DropDownItems.Add(strResearchLinksArray(i, 1))
>  item.tag = i
>
> In the click event:
>
>  Dim index = DirectCast(DirectCast(sender, ToolStripItem).Tag, Integer)
>  dim address = strResearchLinksArray(index, 0)
>
>
> - or -
>
> Create a class inheriting from ToolStripMenuItem and add a property 
> "ServerName".
>
>
>
> -- 
> Armin 


0
Anil
3/7/2010 12:02:58 AM

Am 07.03.2010 01:02, schrieb Anil Gupte/iCinema.com:
> Sorry, I have been unable to connect for a while.  Thanx for your help.
> 
> I am not sure I understand your solution.  You said "in the  click event" 
> and you have me add a line.  My question is, how does one add or assign a 
> click event to each item in the array?

Sorry, only the last question ("How do I go to strResearchLinksArray...")
stayed in my mind. :-) Because you said...

>> OK, so the first part is
>> easy.
>>
>> AdditionalToolStripMenu.DropDownItems.Add(strResearchLinksArray(i, 1))

....I assumed that adding the items already works. To have a procedure handle
an event, use the Addhandler statement:

> dim item =
> AdditionalToolStripMenu.DropDownItems.Add(strResearchLinksArray(i, 1))

      AddHandler item.Click, AddressOf OnMenuItemClick

'...

   Sub OnMenuItemClick(ByVal sender As Object, ByVal e As System.EventArgs)
      'code from last post
   End Sub



-- 
Armin
0
Armin
3/7/2010 12:07:47 PM
Reply:

Similar Artilces:

adding MIme for PDF
When I send a pdf file from Outlook 2003 (Exchange 2003 SP1) it recognizes the pdf file as an application\octet-stream. How can I change this so it recognizes the pdf as a pdf? This is causing issues because application\octet-stream are blocked and pdf's are allowed. Any thoughts? Internet Message Formats in Global Settings -- Bharat Suneja MCSE, MCT -------------------------------- "Bad Beagle" <maxwelli@nospam.postalias> wrote in message news:%23j21Ke8vFHA.2008@TK2MSFTNGP10.phx.gbl... > When I send a pdf file from Outlook 2003 (Exchange 2003 SP1) it recogn...

Anual event notifications
One of our users tells us she is not getting reminders about annual events she has in a 'company calendar' public folder. Ex2003 SP1, O2003 SP2. The event is set up as a meeting. In the Appointment tab, the To: address is her own name. The event is shown as an all day event and the reminder is ticked at 18 hours. The scheduling tab shows she has herself as the meeting organizer and as a required attendee. I've used Exchange Message Tracking set one day early and one day later but can't see anything that could be a notification. Can I track these notifications? Is ...

Remove AD
Dear all, What is the best way to remove AD services from an existing Exchange 2003 server? Thanks. You shouldn't. If Exchange is installed on a Domain Controller, it should not be demoted to a member server. You should install another Exchange server and move mailboxes, replicater public folders, et al. Then remove Exchange from the old server. Now you can demote it to member server. Install Exchange again and move stuff back. -- Bharat Suneja MCSE, MCT www.zenprise.com blog: www.suneja.com/blog ----------------------------------- "KA Kueh" <kka@ksm.com.my> w...

Adding holidays #2
I added US Holidays to my calendar. Outlook added the holidays up to the year 2002 and to the current year or previous year. Any suggestions will be appreciated. Use Office Update to get the latest holidays added. -- Roady [MVP] www.howto-outlook.com Tips of the month: -Creating Signatures -Create an Office XP CD slipstreamed with Service Pack 3 ----- "A E" <selbe@netzero.net> wrote in message news:uDpUEEUREHA.1644@TK2MSFTNGP09.phx.gbl... >I added US Holidays to my calendar. Outlook added the holidays up to the > year 2002 and to the current year or previous yea...

Error when adding new user to CRM
Hello all, I need to add 5 new users into CRM. When I complete the first form for the user information such as Last name, First name, email address, etc, then click the save button I receive an error page and the following message is logged in the Application log. MSCRM Platform Error Report: -------------------------------------------------------------------------------------------------------- Error: The statement has been terminated. Error Message: The statement has been terminated. Error Details: Details on this error have not been provided by the platform. Source File: Not avail...

SBS Exchange 2003: Create new user in AD but no exchange mailbox #3
I'm using SBS 2003. Exchange server is SP2. When I create a new user using Active Directory, it prompts me about creating a mail box. It says it's creating a mailbox, then it's done. But no mailbox appears. In fact, if I use the Exchange tasks wizard, I can create, delete, and recreate the mailbox--all say successful without an error message. And yet, no mailbox. This is even after I reboot the PC and sent email to the address. Any ideas what's going on? mike.aes@gmail.com wrote: > I'm using SBS 2003. Exchange server is SP2. > > When I create a new user ...

If my GP Dynamics support CPA's new cheque standard
Hi; I am using GP Dynamics 8.0 in Canada, we have Payable Management module installed. How can I know if my current version support the CPA's new cheque standard? The CPA's new cheque standard will be launched in July 2007. -- Kane Kane, Support for the new cheque format has nothing to do with the Payables module. Rather, it is a function of modifications or changes to the report that produces your cheque. Lyle On Fri, 22 Sep 2006 10:06:01 -0700, Kane <Kane@discussions.microsoft.com> wrote: >Hi; > >I am using GP Dynamics 8.0 in Canada, we have Payable Managem...

Event ID 9554/Unable to Update Mailbox SD
I am continuing to get the event below; I referenced Microsoft KB 555433 in which it details how to use ADFind Utility to locate the mailbox in question and update the permissions -- however, there is no account in my domain that matches that GUID. Any ideas? Event Type: Warning Event Source: MSExchangeIS Event Category: General Event ID: 9554 Date: 10/6/2005 Time: 8:59:59 AM User: N/A Computer: MY EXCHANGE SERVER Description: Unable to update Mailbox SD in the DS. Mailbox Guid: fe3913d5-a4e0-4c0e-b3b1-291f50d7fc4f. Error Code 0x8004010f For more information, click http://www.microsoft.c...

Disabling / enabling entire menu and toolbar if child window open and has focus
Greetings, I have an MFC app within which a user can choose to go to the company's web site. If they select this from the menu, a CMDIChildWnd is created containing a CHtmlView. I need to have it so when this window is opened, all the menus are disabled and the toolbar is disabled. Also, when the window loses / gets focus, the menus are disabled / enabled respectively. Is there an easy way of doing this? How might I go about it? Thanks for your help! ~simon You can't disable *all* the menu items typically, because you want File>Exit, Help>About, other Help items, etc. en...

OL2007+Exchange: Sent items disappear if i move them to another folder...!
I'm seeing a very strange issue with my Outlook2007 (against Exchange)... Sent items disappear if i move them to another folder...! Steps: 1. Send an email. Sent email gets saved under Outlook's default "Mailbox\SentItems" folder. 2. Go to that SentItems folder, and move the mail to another folder (let's say "Foobar") under your inbox. 3. Go to "Foobar", make sure mail is still there. 4. Let Outlook Sync up with Exchange server (or hit "Send and Receive"). 5. You will notice that the mail disappears... ! I did a full text search in my ...

Adding a VCard to an e-mail using Outlook 2000 and Outlook 2003.
Hello. I have a question. Does anyone here know how to add a VCard to an e-mail in Outlook 2000 as well as in Outlook 2003? I want to be able to do this after I click new and I have a new blank message on my screen. Any and all help would be greatly appreciated. Thank you. -- darylakagod Outlook provides no way to add a vCard .vcf file in this scenario. The built-in way to do it is to start with a contact, not a message, and choose Forward as vCard on the contact's Actions menu. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Admin...

Adding Hyperlink to multiple values within a cell
My spreadsheet contains a list of people. The cell next to each nam contains multiple numeric values for identifying a specific piece o information. I would like to be able to click on one of those number (value) and a comment window pop up with the information associate with it, or be hyperlinked to the information further down th speadsheet. I want to avoid using multiple cells for this. Is this possible? Thank -- t2tru ----------------------------------------------------------------------- t2true's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=387 View this...

Adding additional Public Contact & Calendar Features
Any quick guide to adding additional Contact lists and public features to the public folders for separating to different clients/permissions? 2003 Mike Is there a better Exchange group to ask this? Mike "Michael Gregg" <mike@nospam.alyrica.net> wrote in message news:%23N1DuxJNEHA.556@TK2MSFTNGP10.phx.gbl... > Any quick guide to adding additional Contact lists and public features to > the public folders for separating to different clients/permissions? > > 2003 > > Mike > > ...

Adding BMPs to a form
I use Access 2003. I have a table set up with a field for pictures, this table sits behind a form to add BMPs, which display on the form and print on reports. In the past, when I have had to reinstall Access for any reason, the pictures instead of displaying fully in the form, only show as thumbnails with the file name. I have in the past resoved this by removing Microsoft Picture manager from MS Office. I don't know how I figured that out or why it works but it does. However, I had to reinstall Office yesterday, removed MS Pictrue Manager as usual and it's NOT working ...

adding holidays to a new calendar
I have set up a new calendar that I want to share with my department and I'm trying to add legal holidays which were already on my personal calendar. Even though I'm viewing the new calendar, the holidays got added to the personal calendar. I tried deleting all the holidays and then, with both calendars open, putting the holidays back in, but again they were added only to the personal calendar. Anyone know what to do? Add them to the personal calendar and copy (or move) them to the other calendar. -- Diane Poremsky [MVP - Outlook] Outlook Tips: http://www.outlook-t...

Button Control Event: question
I have a small dialog that prints data it queries from a server to a listbox when a user presses a start button. What I'd like to do is to have the data continually print after the button is pressed until the user presses a stop button. So, I guess I would need to initiate some kind of continuous loop for the data querying/printing, but I'm unsure how to get the stop button to break the loop. If this even the best solution. Does anyone have any ideas of how I could accomplish this, or perhaps a better design idea? Thanks, Marcus Marcus wrote: > I have a small dialog that prints d...

Word/Office Integration as seen at CRM 3.0 Partner Readiness Event
Has anyone seen available resources on integration to Office 2003 applications such as Word?? I saw this demo'd at a Partner Readiness event back in Nov. 2005 and they showed a very tight integration with Word for not only mail merge and easy template building (with CRM fields available), but also a task pane that allowed update/edit of existing CRM records within Word. This was being demo'd as "CRM 3.0 tightly integrated with Office"...Ok, so where is this resource? Also, does anyone know where I can find the supposed 100+ CRM web parts for SharePoint?? thanks, A...

List Box no displaying added choices
I have several drop-down list boxes in a few forms that I am having trouble with. When I originally set up the database, I created the tables and entered a few items to be included in the drop down list in the lookup section of the table (design view). I then created the forms and inserted those fields. I have since added several new choices to the drop-down list of the table, and those new selections are available in the Table, but they are not available in the Form. The only items available in the drop down list on the Form are those choices that were originally there when I set up the fo...

Adding User Name to footer
I have spreadsheets that go out to a number of users, and they make various changes and print out for themselves. The problems is that no-one knows which version to pick up from a central printer. Can I add the user name to the footer. I also have the path and file in the same area. I would like to end up with : User Name printed 'path/file' on 'date' ...

Named Properties Error (Event ID: 9667)
Having problems with good old Event 9667. Thats the problem where Exchange 2003 stop accepting some emails when it hits the 16k soft limit on Named Properties. I've seen the KB article regarding adjusting the size of the named properties cache (if i can call it a cache) up to 32k but, as others have pointed out, that just delays the problem. I would like to know if anyone knows of any good ways to filter headers such that they are reduced to just the standard headers necessary for email delivery? Thanks, K ...

CComboBox shows only one item at a time !
Hi All, I am using CComboBox control and have tried both dropdown and dropddown list styles. The problem is that I have several items in the combo box but dropdown shows only 1 at a time (i.e. the arrows of v-scrollbar are stuck together).. How do I remedy this ? Thanks in advance. Ashish Got it... Thanks "Ashish" <abc@def.com> wrote in message news:eqRb$LSyDHA.2304@TK2MSFTNGP12.phx.gbl... > Hi All, > I am using CComboBox control and have tried both dropdown and dropddown list > styles. The problem is that I have several items in the combo box but > dropdown sho...

how to insert a item when ListCtrl is in "Icon" mode
I create a ListCtrl with "Icon" mode,but I found I can't use the "InsertItem()" to insert a item in a specfied position,the new item is always at the bottom of list,but I want insert some items before a specified position,so how to do it? "pango" <pango99@tom.com> skrev i en meddelelse news:0a1101c3d919$a04cbfa0$a401280a@phx.gbl... > I create a ListCtrl with "Icon" mode,but I found I can't > use the "InsertItem()" to insert a item in a specfied > position,the new item is always at the bottom of list,but > I want i...

retrieving deleted items
If a user deleted a bunch of emails before quitting can I retrieve those without doing a restore? They aren't in her deleted items. if you have DIR configured on that mailbox store, you can recover them by selecting the deleted items folder, and selecting Tools, Recover deleted items from the menu in Outlook... -- Susan Conkey [MVP] "Brandon Baker" <brandon@discussions.microsoft.com> wrote in message news:eW$YsTMOGHA.668@TK2MSFTNGP11.phx.gbl... > If a user deleted a bunch of emails before quitting can I retrieve those > without doing a restore? They aren'...

EVENT ID: 51 & 26
Hi. I'm telecommuting today. I was working happily along when=20 all of a sudden, Windows 2000 Pro froze. Nothing worked,=20 no way to restart so I pushed the restart button. Now, when I try to open Outlook in my profile, the other=20 two on the pc are fine, I get two error messages that=20 basically happen simultaneously. EVENT ID: 51 Event Type: Warning Event Source: Disk Event Category: None Event ID: 51 Date: 6/30/2004 Time: 3:54:18 PM User: N/A Computer: THE-REED-RANCH Description: An error was detected on device \Device\Harddisk1\DR1=20 during a paging operation.=20 Data: 0000: ...

X.400 EVENT 290 Canoot deliver to alternative recipient.
Hi All, I cannot get exchange to deliver emails to "BOTH" the primary mailbox and the alternative recipient. I get a 270 error and a 290 error. This behaviour is only for e-mails coming from the outside (SMTP). If I send an e-mail from outlook to the mailbox that as the alternative recipient it works fine! I tried to setup a distribution list to send to both mailbox, same result 270 and 290 errors. Anybody have any idea? Here's a sample of the 290 error: A non-delivery report (reason code transfer-failure and diagnostic code invalid-arguments) is being generated for...