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_DrawTextonaWindowsForm_snippet_142662_ENU____.3643236F_FC70_11D3_A536_0090278A1BB8 < prev    next >
Extensible Markup Language  |  2008-09-17  |  3KB  |  88 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>Draw Text on a Windows Form</Title>
  6.       <Author>Microsoft Corporation</Author>
  7.       <Description>Draws text on a form.</Description>
  8.       <Shortcut>drawText</Shortcut>
  9.     </Header>
  10.     <Snippet>
  11.       <References>
  12.         <Reference>
  13.           <Assembly>System.Drawing.dll</Assembly>
  14.         </Reference>
  15.         <Reference>
  16.           <Assembly>System.Windows.Forms.dll</Assembly>
  17.         </Reference>
  18.       </References>
  19.       <Imports>
  20.         <Import>
  21.           <Namespace>System</Namespace>
  22.         </Import>
  23.         <Import>
  24.           <Namespace>Microsoft.VisualBasic</Namespace>
  25.         </Import>
  26.         <Import>
  27.           <Namespace>System.Drawing</Namespace>
  28.         </Import>
  29.         <Import>
  30.           <Namespace>System.Windows.Forms</Namespace>
  31.         </Import>
  32.       </Imports>
  33.       <Declarations>
  34.         <Literal>
  35.           <ID>FontName</ID>
  36.           <Type>String</Type>
  37.           <ToolTip>Replace with the font name and size.</ToolTip>
  38.           <Default>"Arial"</Default>
  39.         </Literal>
  40.         <Literal>
  41.           <ID>FontSize</ID>
  42.           <Type>Integer</Type>
  43.           <ToolTip>Replace with the font size.</ToolTip>
  44.           <Default>16</Default>
  45.         </Literal>
  46.         <Object>
  47.           <ID>text</ID>
  48.           <Type>String</Type>
  49.           <ToolTip>Replace with the text to be written.</ToolTip>
  50.           <Default>"hello"</Default>
  51.         </Object>
  52.         <Literal>
  53.           <ID>Xlocation</ID>
  54.           <Type>Single</Type>
  55.           <ToolTip>Replace with the X coordinate for the where the text will appear.</ToolTip>
  56.           <Default>150.0</Default>
  57.         </Literal>
  58.         <Literal>
  59.           <ID>Ylocation</ID>
  60.           <Type>Single</Type>
  61.           <ToolTip>Replace with the Y coordinate for the where the text will appear.</ToolTip>
  62.           <Default>50.0</Default>
  63.         </Literal>
  64.         <Literal>
  65.           <ID>color</ID>
  66.           <ToolTip>Replace with the color of the text.</ToolTip>
  67.           <Default>Color.Red</Default>
  68.         </Literal>
  69.         <Object>
  70.           <ID>form</ID>
  71.           <Type>System.Windows.Forms.Form</Type>
  72.           <ToolTip>Replace with a reference for the form or control to draw the text on.</ToolTip>
  73.           <Default>Me</Default>
  74.         </Object>
  75.       </Declarations>
  76.       <Code Language="VB" Kind="method body"><![CDATA[    Dim drawFormat As New StringFormat()
  77.  
  78.     Using formGraphics As Graphics = $form$.CreateGraphics(), _
  79.         drawFont As New System.Drawing.Font($FontName$, $FontSize$), _
  80.         drawBrush As New SolidBrush($color$)
  81.  
  82.         formGraphics.DrawString($text$, drawFont, drawBrush, _
  83.             $Xlocation$, $Ylocation$, drawFormat)
  84.     End Using
  85. ]]></Code>
  86.     </Snippet>
  87.   </CodeSnippet>
  88. </CodeSnippets>