Drawing a semi-transparent bar over a datagridview problem

Posted on 2009-04-16
Last Modified: 2012-06-22
I am trying to draw a vertical bar over a dgv with mixed success.  Here is what I am doing:

            Dim rec1 As Rectangle
            rec1 = dgvMainGrid.GetCellDisplayRectangle(0, 6, True)
            Dim rec2 As Rectangle
            rec2 = dgvMainGrid.GetCellDisplayRectangle(0, 43, True)
            Dim tpen As New Pen(Color.FromArgb(128, 0, 0, 0), 100)
            Dim grap As Graphics = dgvMainGrid.CreateGraphics
            Dim lint As Point
            Dim linf As Point
            linf.X = rec2.Width / 2
            linf.Y = rec2.Bottom
            lint.X = rec1.Width / 2
            lint.Y = rec1.Bottom + 10
            grap.DrawLine(tpen, linf.X, linf.Y, lint.X, lint.Y)

What I get are gray lines in between rows all the way up to where the bar should end.  It's like the drawing of the dgv cell is taking over and not letting me draw the bar.  Is this what is happening?  Is there a way to draw something on top of a dgv?
Question by:ddepuemd
    LVL 96

    Expert Comment

    by:Bob Learned
    What are you trying to do, and where are you trying to do it?

    Author Comment

    I found some code that creates a transparent progress bar that I simply overlay on top of the grid.  Seems to work fine and actually looks quite nice.
    LVL 96

    Expert Comment

    by:Bob Learned
    Does that mean that my work is done here?

    Author Comment

    Well, it is a solution I can use, but why does the datagrid prevent me from drawing a rectangle over the top of it and filling it in?  
    LVL 96

    Accepted Solution

    "It's like the drawing of the dgv cell is taking over and not letting me draw the bar."
    Yes, that is what is happening.

    Author Comment

    ok thanks - drawing the transparent bar is working...

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now