Hi @Mansour_Dalir ,
Please check if the following code helps. Reset the HScrollBar1.Value after dgv size changed.
Private Sub HScrollBar1_Scroll(sender As Object, e As ScrollEventArgs) Handles HScrollBar1.Scroll
dgv.HorizontalScrollingOffset = e.NewValue
End Sub
Private Sub dgv_Resize(sender As Object, e As EventArgs) Handles dgv.Resize
Dim totalWidth As Integer = dgv.RowHeadersWidth + 1 + dgv.Columns.Cast(Of DataGridViewColumn)().Sum(Function(column) column.Width)
HScrollBar1.Maximum = totalWidth
HScrollBar1.LargeChange = dgv.Width
HScrollBar1.SmallChange = dgv.Columns(0).Width
HScrollBar1.Value = dgv.HorizontalScrollingOffset
End Sub
Best Regards.
Jiachen Li
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.