Let me give you a little more detail about the control.
The control I am hosting is intended to hold a user-configurable number of buttons (the control is aptly named MultiButtonControl). It consists of a UserControl, which holds a FlowLayoutPanel with Dock=Fill, AutoSize = True, AutoSizeMode = GrowAndShrink.
I add buttons to the control and the flow layout panel lays them out and expands for me. This works just fine and works beautifully as a normal Windows Forms control.
However, when I wrap this control in a class called MultiButtonEditingControl, which inherits from my MultiButtonControl and implements the IDataGridViewEditingControl interface, each time the control is activated in the DataGridView it flickers horribly. I have tried setting DoubleBuffer = True on the control itself, to no avail.
One last piece of information - the DataGridViewCell type I'm inheriting my data grid view cell from is DataGridViewImageCell. This means that for my FormattedValue property, I return a blank bitmap; and I override the Paint method and paint a MultiButtonControl for the cells which are not actively being edited.
So, any ideas as to why this is happening Is there some way to double buffer a data grid view cell
If I haven't been sufficiently clear about something, let me know.
Edit:
I should have added, I am using the following piece of code to automatically activate the button cells when the mouse passes over them. This is to avoid the annoying double-click necessary to cause editing controls to become available.
24 Private Sub DataGridView1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseMove
25 Dim ht As DataGridView.HitTestInfo = DataGridView1.HitTest(e.X, e.Y)
26
27 ' Can use this to auto-activate the control
28 If Not ht Is DataGridView.HitTestInfo.Nowhere Then
29 If ht.ColumnIndex >= 0 AndAlso ht.ColumnIndex < DataGridView1.Columns.Count Then
30 Dim col As DataGridViewColumn = DataGridView1.Columns(ht.ColumnIndex)
31
32 If TypeOf (col) Is DataGridViewMultiButtonColumn Then
33 If Not ht.RowIndex = DataGridView1.NewRowIndex AndAlso ht.RowIndex >= 0 _
34 AndAlso ht.RowIndex < DataGridView1.RowCount Then
35 'Console.WriteLine("Blah Blah Activating")
36 DataGridView1.CurrentCell = DataGridView1.Rows(ht.RowIndex).Cells(ht.ColumnIndex)
37 DataGridView1.BeginEdit(True)
38 Else
39 'Console.WriteLine("Blah blah")
40 End If
41 Else
42 'Console.WriteLine("Nope nope")
43 End If
44 End If
45 End If
46 End Sub
Upon further inspection, the cells are flickering not when the mouse enters, the cell, but when it exits - when the DataGridView replaces the editing control with the image representing it.
I have tried deriving from DataGridView and enabling double buffering, but it doesn't help.
Any ideas