EditingPanel Erasing Top Cell Border
-
This maybe academic but here goes anyway... I'm drawing custom borders for a datagridview in the datagridview's paint event, the one in a Windows form. That works fine until I edit a cell. When I edit a cell, the top and left grid borders (which are drawn by me in the grid's paint event) are over-layed by the EditingPanel control of the datagridview class. So the borders disappears and the cell looks like it has only two borders...bottom...and right. I subsequently created a custom column and cell template for the grid but no matter what I've tried so far, I can't get to the event that's overwriting my borders to either have it paint the missing borders themselves, or stop it from overwriting the ones that I'm drawing. It would seem that this type of task needs to be accomplished all the time and I just don't know how...so I'm totally missing the boat on this one. Would someone please let me in on the secret of how to (the proper procedures) for painting custom borders around the datagridview cell I'm editing? The borders should be in alignment with the grid's boarders and have the ability to be drawn in different colors. Please advise and thanks!!! Mark
-
This maybe academic but here goes anyway... I'm drawing custom borders for a datagridview in the datagridview's paint event, the one in a Windows form. That works fine until I edit a cell. When I edit a cell, the top and left grid borders (which are drawn by me in the grid's paint event) are over-layed by the EditingPanel control of the datagridview class. So the borders disappears and the cell looks like it has only two borders...bottom...and right. I subsequently created a custom column and cell template for the grid but no matter what I've tried so far, I can't get to the event that's overwriting my borders to either have it paint the missing borders themselves, or stop it from overwriting the ones that I'm drawing. It would seem that this type of task needs to be accomplished all the time and I just don't know how...so I'm totally missing the boat on this one. Would someone please let me in on the secret of how to (the proper procedures) for painting custom borders around the datagridview cell I'm editing? The borders should be in alignment with the grid's boarders and have the ability to be drawn in different colors. Please advise and thanks!!! Mark
I guess a few hours of sleep help sometimes...I think that this is the way... Private Sub Grid_CellPainting(sender As Object, e As System.Windows.Forms.DataGridViewCellPaintingEventArgs) Handles Grid.CellPainting Try 'Paint the cell if the edit control is visible If Grid.EditingControl IsNot Nothing Then Dim g As Graphics = Graphics.FromHwnd(Grid.EditingPanel.Handle) g.DrawRectangle(Pens.Red, Grid.EditingPanel.ClientRectangle) g.Dispose() End If Catch ex As Exception Debug.print(ex.Message) End Try End Sub