开发者

How do I override Microsoft's datagridview to allow back buffering in VB.NET?

My datagridview flickers and is very slow while loading. I reflecto开发者_高级运维red 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?


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.


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


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.


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜