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

前端 未结 4 1282
旧巷少年郎
旧巷少年郎 2021-02-08 07:32

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 f

相关标签:
4条回答
  • 2021-02-08 07:53

    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.

    0 讨论(0)
  • 2021-02-08 07:53

    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.

    0 讨论(0)
  • 2021-02-08 07:59

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

    0 讨论(0)
  • 2021-02-08 08:15

    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 讨论(0)
提交回复
热议问题