C# DataGridView每1秒更新一次,但垂直滚动条未正确显示

C# DataGridView每1秒更新一次,但垂直滚动条未正确显示,c#,.net,winforms,datagridview,scrollbar,C#,.net,Winforms,Datagridview,Scrollbar,我开发了一个应用程序,其中dataGridView大约每秒更新一次。我正在启用两个滚动条。垂直滚动条按钮向下和向上不显示。我无法滚动垂直滚动条。另外,如果我启用显示最后一行作为第一个滚动索引应用程序挂起 当我在VisualStudio环境中运行应用程序时,它工作得很好。只有在VisualStudio环境之外执行时,我才会观察到这种行为 请查找下面的网格更新代码 private static void UpdateGrid(DataTable table) { JSONTest form

我开发了一个应用程序,其中dataGridView大约每秒更新一次。我正在启用两个滚动条。垂直滚动条按钮向下和向上不显示。我无法滚动垂直滚动条。另外,如果我启用显示最后一行作为第一个滚动索引应用程序挂起

当我在VisualStudio环境中运行应用程序时,它工作得很好。只有在VisualStudio环境之外执行时,我才会观察到这种行为

请查找下面的网格更新代码

private static void UpdateGrid(DataTable table)
{
    JSONTest form = (JSONTest)Application.OpenForms["JSONTest"];
    if (form.GridTestReport.InvokeRequired)
    {
        UpdateGridThreadHandler handler = UpdateGrid11;
        form.GridTestReport.BeginInvoke(handler, table);
    }
    else
    {                
        form.GridTestReport.DataSource = table;           
    }
}

private static void UpdateGridView()
{
    JSONTest form = (JSONTest)Application.OpenForms["JSONTest"];
    if (form.GridTestReport.InvokeRequired)
    {
        UpdateGridViewCallback d = new UpdateGridViewCallback(UpdateGridView);
        form.GridTestReport.Invoke(d);
    }
    else
    {
        foreach (DataGridViewRow row in form.GridTestReport.Rows)
        {
            if (row.Cells[2].Value.ToString() == "FAIL")
            {
                row.DefaultCellStyle.ForeColor = Color.Red;
            }
            else
            {
                row.DefaultCellStyle.ForeColor = Color.Green;
            }
            row.Cells["RowNumber"].Value = row.Index + 1;
        }
        //if (form.GridTestReport.RowCount > 5)
        //{
        //    form.GridTestReport.FirstDisplayedScrollingRowIndex = form.GridTestReport.RowCount - 1;
        //}                

        form.lbl_Response.Text = "Received Response :" + TestSuitADU.countReceivedResponse.ToString();
        form.lbl_Request.Text = "Sent Request:" + RandomExecution.CountRequest.ToString();
        if (form.TestClasses_combox.SelectedItem == "Batch")
        {
            form.lbl_Request.Text = "Sent Request:" + TestSuitADU.CountRequestResponse.ToString();
        }
    }
}