Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Showing a contextMenu
Message
De
19/03/2003 19:23:29
 
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Divers
Thread ID:
00767833
Message ID:
00767898
Vues:
13
Kirk,

I'm not sure exactly what you mean ... but I'll take a stab at it.

You need to have an event handler to handle the popup (maybe you already have that, since you say you've add two menu options to it). You also need a Click event handler for the items in your list. Here's a sample ... hope you don't mind C# code (I don't know what the VB syntax is):
// First the delegate for the popup handler:
this.oContextMenu.Popup += new System.EventHandler(this.PopupHandler);

// Now the Popup Handler
private void PopupHandler(object sender, System.EventArgs e)
{
  // Here's where you add your Context Menu items and set up the click event handler
  this.oContextMenu.MenuItems.Clear();
  MenuItem oItem;

  oItem = new MenuItem("First Choice");
  oItem.Click += new System.EventHandler(this.oMenuHandler);
  this.oContextMenu.MenuItems.Add(oItem);

  oItem = new MenuItem("Second Choice");
  oItem.Click += new System.EventHandler(this.oMenuHandler);
  this.oContextMenu.MenuItems.Add(oItem);
}

// And lastly, the Click event handler
private void oMenuHandler(object sender, System.EventArgs e)
{
  MenuItem item = (MenuItem)sender;
  switch (item.Text)
  {
    case "First Choice" :
      // put code here
      break;
    case "Second Choice" :
      // put code here
      break;
  }
}
HTH,
~~Bonnie


>I have added a ContextMenu object to my form and given it two menu options. It is not associated with a control via the contextmenu. Instead I need to call it manually, anybody know how to do that?
>
>Thanks
>Kirk
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform