<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>Hook into the paint event for myButton. Create a new graphics object</Title>
      <Shortcut>HookintothepainteventformyButton.Createanewgraphicsobject</Shortcut>
      <Description>Hook into the paint event for myButton. Create a new graphics object [C#]</Description>
      <Author>Robert Wagner</Author>
      <HelpUrl>/PreviewSnippet.aspx?SnippetID=241b14bd-ea7c-4964-80c2-8867eaa0274f</HelpUrl>
      <SnippetTypes>
        <SnippetType>SurroundsWith</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Code Language="csharp"><![CDATA[// hook into control paint events change their appearance
// standard Button control does not have properties to control the 
// border size or color. In this code , you hook into the button’s Paint event and 
// modify its appearance.
private void ChangeButtonBorder(object sender, System.Windows.Forms.PaintEventArgs e) 
{
    // Hook into the paint event for myButton. Create a new graphics object
    // and paint a custom border around the button.
    
	System.Drawing.Graphics g = e.Graphics;
	
	int BorderWidth = 3;
	System.Drawing.Color BorderColor = System.Drawing.Color.Blue; 
	
	System.Windows.Forms.ControlPaint.DrawBorder( 
		g, e.ClipRectangle, BorderColor, BorderWidth, 
		System.Windows.Forms.ButtonBorderStyle.Solid, BorderColor, BorderWidth, 
		System.Windows.Forms.ButtonBorderStyle.Solid, BorderColor, BorderWidth, 
		System.Windows.Forms.ButtonBorderStyle.Solid, BorderColor, BorderWidth, 
		System.Windows.Forms.ButtonBorderStyle.Solid);
}]]></Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>