|
-
March 4th, 2009, 03:17 AM
#1
[RESOLVED] [2005]OwnerDrawing the Listview ColumnHeaders to 2003/2007 Office look-and-feel
Anyone who could provide me a direction to start with? Any other look that is not dull is also very much welcome!
-
March 4th, 2009, 04:03 AM
#2
Re: [2005]OwnerDrawing the Listview ColumnHeaders to 2003/2007 Office look-and-feel
This is my effort. I am failing to fill the entire ColumnHeader with my gradient, why so?
Code:
private Bitmap GetVerticalGradient()
{
Bitmap Gradient = new Bitmap(1, 2);
Gradient.SetPixel(0, 0, ProfessionalColors.ToolStripGradientBegin);
Gradient.SetPixel(0, 1, ProfessionalColors.ToolStripGradientEnd);
return Gradient;
}
private void listView1_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
{
//e.Graphics.DrawImage(GetVerticalGradient(), e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height); //then we draw an outline
e.Graphics.DrawImage(GetVerticalGradient(), new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height), new Rectangle(0, 0, GetVerticalGradient().Width,GetVerticalGradient().Height), GraphicsUnit.Pixel);
e.Graphics.DrawString(e.Header.Text, new Font("tahoma", 8), new SolidBrush(Color.Black), e.Bounds);
}
-
March 4th, 2009, 10:57 PM
#3
Re: [2005]OwnerDrawing the Listview ColumnHeaders to 2003/2007 Office look-and-feel
How about this?
Code:
Public Class thisRenderer
Inherits System.Windows.Forms.ToolStripRenderer
Protected Overrides Sub OnRenderToolStripBackground(ByVal e As ToolStripRenderEventArgs)
MyBase.OnRenderToolStripBackground(e)
Dim b As New Drawing2D.LinearGradientBrush(e.AffectedBounds, Color.WhiteSmoke, e.BackColor, _
Drawing2D.LinearGradientMode.Vertical)
e.Graphics.FillRectangle(b, e.AffectedBounds)
End Sub
End Class
' this could be called in a form like this:
' ToolStrip1.Renderer = New myRenderer
-
March 5th, 2009, 12:47 AM
#4
Re: [2005]OwnerDrawing the Listview ColumnHeaders to 2003/2007 Office look-and-feel
Thanks! With your suggestion I came up with this which was better than my previous implementation. The problem now is that it is no longer catching mousehover and mousedown.
Code:
private void listView1_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
{
System.Drawing.Drawing2D.LinearGradientBrush b = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height), ProfessionalColors.ToolStripGradientBegin, ProfessionalColors.ToolStripGradientEnd, System.Drawing.Drawing2D.LinearGradientMode.Vertical);
e.Graphics.FillRectangle(b, new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height));
e.Graphics.DrawLine(Pens.LightSkyBlue, e.Bounds.Right - 2, e.Bounds.Top, e.Bounds.Right - 2, e.Bounds.Bottom);
e.Graphics.DrawString(e.Header.Text, new Font("tahoma", 9), new SolidBrush(Color.Black), e.Bounds);
}
Sorry, got to spread first. =(
-
March 5th, 2009, 01:34 AM
#5
Re: [RESOLVED] [2005]OwnerDrawing the Listview ColumnHeaders to 2003/2007 Office look
Didn't see any mention of that in your last post!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|