Home>

We are proceeding so that data can be viewed using DataGridView.
I wanted to add a header to a line and had a problem during the initialization phase.
I researched various things about adjusting the position of the scroll bar, but I couldn't find any information, so I would appreciate it if you could teach me. Thank you.

The problem i am having

I'm initializing a DataGridView, but a vertical scroll is displayed in the grit.
(Scrolling itself is possible)

Corresponding source code
      'Data grid view initialization (number of data 4 x 2 (A/B))
        For i As Integer = 1 To 4
            Dim row As Integer = DG1.Rows.Add ()
            DG1.Rows (row) .HeaderCell.Value = "No" + i.ToString () + "-A"
        Next
        For i As Integer = 1 To 4
            Dim row As Integer = MesDispLeak.Rows.Add ()
            DG1.Rows (row) .HeaderCell.Value = "No" + i.ToString () + "-B"
        Next
        DG1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
        DG1.RowHeadersWidth = 80
        DG1.Refresh ()
What I tried

1) Scrolling does not occur without adding content (obviously ... as a separation)

2) Reset the scroll position

      DG1.RowHeadersWidth = 80
        DG1.ScrollBars = ScrollBars.None
        DG1.ScrollBars = ScrollBars.Both
        DG1.Refresh ()


Supplementary information (FW/tool version, etc.)

OS: Windows 10
Development environment: Visual Studio 2017/.Net 4.0

  • Answer # 1

    The cause was that the following code was written in the sizeChanged of the form.

    Me.SuspendLayout ()