如何在Windows窗体中刷新表单? [英] How to refresh a form in windows form?

查看:79
本文介绍了如何在Windows窗体中刷新表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有一个gridview,它包含no.of记录。如果我向下滚动50或任何其他记录然后如果我通过按钮刷新表单,我将失去我当前的位置并自动进入第1记录。我希望在同一位置的记录甚至在刷新后说50。请帮帮我...



提前谢谢。

Hi,

I have one gridview and it contains no.of records. if i have scroll down for 50th or any other record then if i refresh the form through a button, i will lose my current positon and automatically comes to 1st record. I want the record at the same position say 50 even after refreshing. Please help me...

Thanks in advance.

推荐答案

我使用的是DataGridView'' FirstDisplayedScrollingRowIndex Property [ ^ ]



像这样:(我的DataGridView名为gvMast)



I use the DataGridView''s FirstDisplayedScrollingRowIndex Property[^]

Like this: (my DataGridView is named gvMast)

'Variable to save the scrolling index with
    Private intSaveScrollingIndex As Integer = 0

    'When user scrolls the grid, save the index
    Private Sub gvMast_Scroll(ByVal sender As Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles gvMast.Scroll
        intSaveScrollingIndex = gvMast.FirstDisplayedScrollingRowIndex
    End Sub

    'When the grid is refreshed, scroll the grid back to the proper place if possible
    Private Sub LoadGrid()
        ' *** Whatever code you have that reloads/refreshed your grid goes here *** '

        'If filters or changes have removed rows to scroll to, or have removed ALL rows, reset the scrolling index to zero
        If gvMast.Rows.Count <= intSaveScrollingIndex _
        OrElse intSaveScrollingIndex = -1 Then
            intSaveScrollingIndex = 0
        End If

        'Only set scrolling index when there are rows to display
        If gvMast.Rows.Count > 0 Then
            gvMast.FirstDisplayedScrollingRowIndex = intSaveScrollingIndex
        End If
    End Sub


http://stackoverflow.com/questions/2433024/how-to-reload-windows-form-without-closing-it-using-vb-net [ ^ ]



或使用 Control.Refresh方法 [ ^ ]


这篇关于如何在Windows窗体中刷新表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆