Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Windows
I have created a form in which i want to execute the following code
 

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 1-Apr-13 23:39pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
 
Add a Paint event[^] to your form:
public Form1()
{
     InitializeComponent();
     this.Paint += Form1_Paint;
}
And in the Form1_Paint method:
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
     DrawVisualStyleElementExplorerBarHeaderPin1(e);
}
Hope this helps.
  Permalink  
Comments
Kalpesh_Bhadra at 2-Apr-13 5:24am
   
thank you ProgramFOX
ProgramFOX at 2-Apr-13 5:29am
   
You're welcome!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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

public Form1()
{
            InitializeComponent();
}
 
private void Form1_Paint(object sender, PaintEventArgs e)
{
            DrawVisualStyleElementExplorerBarHeaderPin1(e);
}
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 250
1 Jochen Arndt 155
2 PIEBALDconsult 150
3 DamithSL 125
4 Afzaal Ahmad Zeeshan 120
0 OriginalGriff 5,695
1 DamithSL 4,591
2 Maciej Los 4,012
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 29 Jun 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100