1
두 개의 DataGridView 컨트롤이 있습니다. 두 개의 DataGridView 컨트롤은 세 개의 단추가 세로로 놓여 있으며 크기를 조정하고 폼의 크기를 조절해야하는 VB 2005 형식으로되어 있습니다.크기를 조정할 수있는 창에서 컨트롤의 크기를 조정하는 방법은 무엇입니까?
아래 코드는 작동하며 내가 원하는 것을 수행합니다. 새로운 크기와 기본 크기 사이의 차이를 취하고 두 DataGridView 사이의 높이 차이를 나눠서 올바르게 이동합니다.
기본적으로 ResizeEnd 핸들러에 기본값을 하드 코딩했는지 버그가 있습니다. 나 자신을 반복하지 않도록 기본 크기를 전달하는 방법은 무엇입니까?
코드를 작성할 필요가 없도록 앵커링, 도킹 및 기타 작업을 수행하는 것이 더 좋습니다.
미리 감사드립니다.
Private Sub dlgShowAssets_ResizeEnd(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.ResizeEnd
Dim defaultWindowSize As New System.Drawing.Size(759, 619)
Dim defaultAssetDGVSize As New System.Drawing.Size(730, 153)
Dim defaultAssetDGVPos As New System.Drawing.Point(9, 186)
Dim defaultButton1Pos As New System.Drawing.Point(9, 345)
Dim defaultButton2Pos As New System.Drawing.Point(100, 345)
Dim defaultButton3Pos As New System.Drawing.Point(191, 345)
Dim defaultDetailDGVSize As New System.Drawing.Size(730, 177)
Dim defaultDetailDGVPos As New System.Drawing.Point(9, 374)
Dim deltaX As Integer = Me.Size.Width - defaultWindowSize.Width
Dim deltaY As Integer = Me.Size.Height - defaultWindowSize.Height
Dim deltaSize As New System.Drawing.Size(deltaX, deltaY/2)
Dim deltaPos As New System.Drawing.Point(0, deltaY/2)
Me.AssetDataGridView.Size = defaultAssetDGVSize + deltaSize
Me.btnAddAsset.Location = defaultButton1Pos + deltaPos
Me.btnEditAsset.Location = defaultButton2Pos + deltaPos
Me.btnDeleteAsset.Location = defaultButton3Pos + deltaPos
Me.AssetIdentifierDataGridView.Size = defaultDetailDGVSize + deltaSize
Me.AssetIdentifierDataGridView.Location = defaultDetailDGVPos + deltaPos
End Sub
빙고! 고맙습니다! – John
후속 조치 - 제안을 통해이 작업에서 5,000 %의 생산성 향상을 기대할 수있었습니다. 오늘 밤 내 앱에서 모든 양식을 크기를 조정할 수 있습니다. 다시 한 번 감사드립니다! – John