|
■No58879 (shu さん) に返信
> Windowメッセージを取得してやればなんとか出来るかもしれません。
無理矢理サイズを指定し続けてみました。……が、右下部の再描画を
何とかしなければならないので、これだけでは駄目そう。
Public Class Form1
Private WithEvents DGV As DataGridView
Private WithEvents HS As HScrollBar
Private WithEvents VS As VScrollBar
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
DGV = New DataGridView()
DGV.Dock = DockStyle.Fill
Controls.Add(DGV)
DGV.ColumnCount = 5
DGV.RowCount = 20
HS = DGV.Controls.OfType(Of HScrollBar)().FirstOrDefault()
VS = DGV.Controls.OfType(Of VScrollBar)().FirstOrDefault()
DGV.SuspendLayout()
VS.SetBounds(0, 0, 0, 0)
HS.SetBounds(0, 0, 0, 0)
DGV.ResumeLayout()
End Sub
Private Sub VS_LocationChanged(ByVal sender As Object, ByVal e As EventArgs) Handles VS.LocationChanged
Dim VW As Integer = SystemInformation.VerticalScrollBarWidth * 2
Dim L As Integer = DGV.Right - VW
If VS.Left <> L Then
VS.Left = L
End If
End Sub
Private Sub VS_SizeChanged(ByVal sender As Object, ByVal e As EventArgs) Handles VS.SizeChanged
Dim VW As Integer = SystemInformation.VerticalScrollBarWidth * 2
If VS.Width <> VW Then
VS.Width = VW
End If
Dim HH As Integer = SystemInformation.HorizontalScrollBarHeight * 2
Dim VH As Integer = If(HS.Visible, DGV.Height - HH, DGV.Height)
If VS.Height <> VH Then
VS.Height = VH
End If
End Sub
Private Sub HS_LocationChanged(ByVal sender As Object, ByVal e As EventArgs) Handles HS.LocationChanged
Dim HH As Integer = SystemInformation.HorizontalScrollBarHeight * 2
Dim T As Integer = DGV.Bottom - HH
If HS.Top <> T Then
HS.Top = T
End If
End Sub
Private Sub HS_SizeChanged(ByVal sender As Object, ByVal e As EventArgs) Handles HS.SizeChanged
Dim HH As Integer = SystemInformation.HorizontalScrollBarHeight * 2
If HS.Height <> HH Then
HS.Height = HH
End If
End Sub
End Class
|