views:

59

answers:

4

My datagridview flickers and is very slow while loading. I reflectored the datgridview from Microsoft and discovered that there is a back buffer property which is not visible from the winForm. How do I set this property?

+9  A: 

For some reason Microsoft put the DoubleBuffered property in there, but didn't allow us to turn it on. You can hijack the system by using SubClassing.

Public Class MyDataGridView
   Inherits DataGridView

   Sub New()  
      MyBase.New()

      Me.DoubleBuffered = True
   End Sub
End Class

In your program you can then Build it and the new class should pop up in your toolbox. Once there you are free to drag it out and use it as if it were a normal DataGridView with better drawing capabilities.

Hope this helps.

Jimmie Clark
Why did you make your post community wiki?
Tim Schmelter
I'm new to this, not sure what it was. If it is a wiki where this could be useful I wanted to add it.
Jimmie Clark
+5  A: 

I would use a listview, it does not have the same problems as a datagridview does.

TheAssassin83
+4  A: 

I try to use datagridview's as little as possible as they are very complex. I would use a listbox as it populates much quicker.

Stack Guy
+3  A: 

How about trying a List and adding it programmatically to a multiline textbox. That is very fast and efficient.

 Dim tbox As New TextBox

    Dim bobs As New List(Of String)

    bobs.Add("Williams")
    bobs.Add("Stephens")
    bobs.Add("Thomas")
    bobs.Add("Brown")
    bobs.Add("Knauff")

    For Each str As String In dinosaurs
      tbox.Text &= str & vbNewLine ' &= ensures you add the str not overwrite the previous data/vbnewline works as a cr(carriage return) and an lf(line feed)'
    Next
FB_ME_tsSE