Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a form in which i want to execute the following code


C#
public void DrawVisualStyleElementExplorerBarHeaderPin1(PaintEventArgs e)
{
    if (VisualStyleRenderer.IsElementDefined(
        VisualStyleElement.ExplorerBar.HeaderPin.Normal))
    {
        VisualStyleRenderer renderer =
             new VisualStyleRenderer(VisualStyleElement.ExplorerBar.HeaderPin.Normal);
        Rectangle rectangle1 = new Rectangle(10, 50, 50, 50);
        renderer.DrawBackground(e.Graphics, rectangle1);
        e.Graphics.DrawString("VisualStyleElement.ExplorerBar.HeaderPin.Normal",
             this.Font, Brushes.Black, new Point(10, 10));
    }
    else
        e.Graphics.DrawString("This element is not defined in the current visual style.",
             this.Font, Brushes.Black, new Point(10, 10));
}


and i don't know how to use this code. my senior told me to use this code and he has given link which is as follow
please help to get ride out of it.
link is:- http://msdn.microsoft.com/en-us/library/system.windows.forms.visualstyles.visualstyleelement.explorerbar.headerpin.aspx?cs-save-lang=1&cs-lang=csharp[^]
Posted

C#
private void InitializeComponent()
{
............
            this.Name = "Form1";
            this.Text = "Form1";
            this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
            this.ResumeLayout(false);

}



C#
public Form1()
{
            InitializeComponent();
}

private void Form1_Paint(object sender, PaintEventArgs e)
{
            DrawVisualStyleElementExplorerBarHeaderPin1(e);
}
 
Share this answer
 
Hi,

Add a Paint event[^] to your form:
C#
public Form1()
{
     InitializeComponent();
     this.Paint += Form1_Paint;
}

And in the Form1_Paint method:
C#
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
     DrawVisualStyleElementExplorerBarHeaderPin1(e);
}

Hope this helps.
 
Share this answer
 
Comments
Kalpesh_Bhadra 2-Apr-13 5:24am    
thank you ProgramFOX
Thomas Daniels 2-Apr-13 5:29am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900