1

我可以在面板上一个接一个地添加多个 datagridview 1。

通过添加来自同一论坛的 SysDragon 代码

    Dim AllDataGrids As List(Of My_custom_DGV)
    Dim lastCtrl As Control
    AllDataGrids = New List(Of My_custom_DGV)

    For j As Int32 = 0 To 3

        Dim aDataGridView As New My_custom_DGV()
        aDataGridView.for_date = ""
        aDataGridView._count = week_count

        aDataGridView.Dock = DockStyle.Top
        aDataGridView.Dock = DockStyle.Right
        aDataGridView.Dock = DockStyle.Left
        aDataGridView.Dock = DockStyle.Bottom


        AllDataGrids.Add(aDataGridView)


    Next j

    For i As Integer = 1 To 3
        Dim dgv As My_custom_DGV = AllDataGrids(i)
        ' Dim dgv As DataGridView = AllDataGrids(i)

        If dataGrid_Panel.Controls.Count.Equals(0) Then
            dgv.Top = DataGridView1.Height + 20
        Else
            lastCtrl = dataGrid_Panel.Controls(dataGrid_Panel.Controls.Count - 1)
            dgv.Top = lastCtrl.Top + lastCtrl.Height + 5

        End If

        dataGrid_Panel.Controls.Add(dgv)

    Next

问题是当我在它们之间滚动时,它看起来很糟糕(即当我滚动时,它会一次又一次地重复面板上的图像)。当我滚动时它是否再次渲染视图,并且可能重复调用datagridview的绘制方法。如果是,那么解决方案是什么?谢谢。

4

0 回答 0