【问题标题】:Selected row flickers when scrolling滚动时选定的行闪烁
【发布时间】:2013-01-13 14:30:54
【问题描述】:

我在 dgv "fill" 形成区域的 Form 中用 5000 行数据限制了 DataGridView。 当我用键盘向上或向下滚动它时,选定的行在固态计算机上闪烁很多。 有没有办法消除这种闪烁?

这是我的DataGridView 的设置方式:

    With DataGridView1
        .AllowUserToAddRows = False
        .AllowDrop = False
        .AllowUserToOrderColumns = False
        .AllowUserToResizeRows = False
        .ColumnHeadersDefaultCellStyle.Font = fnt1
        .SelectionMode = DataGridViewSelectionMode.FullRowSelect
        .ScrollBars = ScrollBars.Vertical
        .MultiSelect = False
        .ReadOnly = True
        .DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft
        .GridColor = Color.FromArgb(240, 240, 240)
        .DefaultCellStyle.Font = fnt1
        .BorderStyle = BorderStyle.None
        .Dock = DockStyle.Fill
     End With

【问题讨论】:

    标签: vb.net datagridview


    【解决方案1】:

    您可以通过为该表单实现双缓冲来消除闪烁

    me.SetStyle(
    ControlStyles.AllPaintingInWmPaint OR _
    ControlStyles.UserPaint OR _
    ControlStyles.DoubleBuffer,true)
    

    这应该可以工作

    【讨论】:

    • 双缓冲表单不会自动双缓冲子控件。
    • 嗨塞利姆。正如 Lars 所说,这对我的 datagridview 没有帮助。
    【解决方案2】:

    然后尝试this

    希望对你有帮助

    【讨论】:

    • 我已经使用这个 .GetType.InvokeMember"DoubleBuffered", Reflection.BindingFlags.NonPublic 或 _ Reflection.BindingFlags.Instance 或 _ System.Reflection.BindingFlags.SetProperty, _ Nothing, DataGridView1, New Object( ) {True}),但仍有闪烁。
    猜你喜欢
    • 2015-07-22
    • 2018-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多