• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 293
  • Last Modified:

Drawing a semi-transparent bar over a datagridview problem

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)
            grap.Dispose()

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?
0
ddepuemd
Asked:
ddepuemd
  • 3
  • 3
1 Solution
 
Bob LearnedCommented:
What are you trying to do, and where are you trying to do it?
0
 
ddepuemdAuthor Commented:
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.
0
 
Bob LearnedCommented:
Does that mean that my work is done here?
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
ddepuemdAuthor Commented:
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?  
0
 
Bob LearnedCommented:
"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.
0
 
ddepuemdAuthor Commented:
ok thanks - drawing the transparent bar is working...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now