Results 1 to 2 of 2

Thread: [RESOLVED] DataGridView RowHeaders

  1. #1

    Thread Starter
    Fanatic Member Jumpercables's Avatar
    Join Date
    Jul 2005
    Location
    Colorado
    Posts
    592

    Resolved [RESOLVED] DataGridView RowHeaders

    I've created a custom class that inherits from the standard DataGridView that displays both Columns and Row Headers. I'm looking to alter the color of the top left cell in the DataGridView (above the first RowHeader and to the left of the first Column), but I cannot seem to find the correct method override to accomplish this task.

    Does anyone have an idea of the method or if it's possible?

    Thanks
    Last edited by Jumpercables; Feb 11th, 2010 at 05:30 PM. Reason: Removed Title

    C# - .NET 1.1 / .NET 2.0

    "Take everything I say with a grain of salt, sometimes I'm right, sometimes I'm wrong but in the end we've both learned something."
    _____________________
    Regular Expressions Library
    Connection String
    API Functions
    Database FAQ & Tutorial

  2. #2

    Thread Starter
    Fanatic Member Jumpercables's Avatar
    Join Date
    Jul 2005
    Location
    Colorado
    Posts
    592

    Re: DataGridView RowHeaders

    If anyone is interested I have found a workaround. You need to override the OnPaint event of the DataGridView and draw or place your control into that X,Y location.

    Code:
     protected override void OnPaint(PaintEventArgs e)
     {
                base.OnPaint(e);
    
                // Draw over the TopLeftHeader.
                Rectangle cellBounds = new Rectangle(0, 0, this.RowHeadersWidth, this.ColumnHeadersHeight);
                LinearGradientBrush lgb = new LinearGradientBrush(cellBounds, Color.FromArgb(245, 245, 245), Color.FromArgb(220, 220, 220), LinearGradientMode.Vertical);
    
                e.Graphics.FillRectangle(lgb, cellBounds);
    }

    C# - .NET 1.1 / .NET 2.0

    "Take everything I say with a grain of salt, sometimes I'm right, sometimes I'm wrong but in the end we've both learned something."
    _____________________
    Regular Expressions Library
    Connection String
    API Functions
    Database FAQ & Tutorial

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width