home *** CD-ROM | disk | FTP | other *** search
/ ftp.tcs3.com / ftp.tcs3.com.tar / ftp.tcs3.com / DRIVERS / Audio / Office2010 / InfoPath.en-us / InfLR.cab / FL_AddAContextMenuToAWindowsForm_snippet_142610_ENU____.3643236F_FC70_11D3_A536_0090278A1BB8 < prev    next >
Extensible Markup Language  |  2008-09-17  |  2KB  |  53 lines

  1. <?xml version="1.0"?>
  2. <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  3.   <CodeSnippet Format="1.0.0">
  4.     <Header>
  5.       <Title>Add a Context Menu to a Windows Form</Title>
  6.       <Author>Microsoft Corporation</Author>
  7.       <Description>Adds a context menu to a windows form.</Description>
  8.       <Shortcut>menuContext</Shortcut>
  9.     </Header>
  10.     <Snippet>
  11.       <References>
  12.         <Reference>
  13.           <Assembly>System.Windows.Forms.dll</Assembly>
  14.         </Reference>
  15.       </References>
  16.       <Imports>
  17.         <Import>
  18.           <Namespace>System.Windows.Forms</Namespace>
  19.         </Import>
  20.       </Imports>
  21.       <Declarations>
  22.         <Object>
  23.           <ID>form</ID>
  24.           <Type>Form</Type>
  25.           <ToolTip>Replace with the form where the context menu should appear.</ToolTip>
  26.           <Default>Me</Default>
  27.         </Object>
  28.         <Literal>
  29.           <ID>secondItem</ID>
  30.           <Type>String</Type>
  31.           <ToolTip>Replace with text for the second item in the menu.</ToolTip>
  32.           <Default>"&Second Item"</Default>
  33.         </Literal>
  34.         <Literal>
  35.           <ID>firstItem</ID>
  36.           <Type>String</Type>
  37.           <ToolTip>Replace with text for the first item in the menu.</ToolTip>
  38.           <Default>"&First Item"</Default>
  39.         </Literal>
  40.       </Declarations>
  41.       <Code Language="VB" Kind="method decl"><![CDATA[Dim newMenu As New ContextMenuStrip()
  42. $form$.ContextMenuStrip = newMenu
  43.  
  44. Dim firstItem As New ToolStripMenuItem()
  45. Dim secondItem As New ToolStripMenuItem()
  46. firstItem.Text = $firstItem$
  47. secondItem.Text = $secondItem$
  48.  
  49. newMenu.Items.Add(firstItem)
  50. newMenu.Items.Add(secondItem)]]></Code>
  51.     </Snippet>
  52.   </CodeSnippet>
  53. </CodeSnippets>