Visual Basic: Windows Controls

ComputeControlSize Method Example

The example uses the ComputeControlSize method to calculate how large a MonthView control will be after increasing it's size using the MonthRows and MonthColumns properties. To try the example, place a MonthView control on a form and paste the code into the Declarations section of the code module. Start the project and double-click the form.

  Private Sub Form_Load()
   ' Set the Top and Left properties of the control.
   With MonthView1
      .Left = 200 ' Assuming ScaleMode = Twip
      .Top = 400
   End With
End Sub

Private Sub Form_DblClick()
   Dim sWidth As Single
   Dim sHeight As Single

   With MonthView1 ' Compute the control size and add columns and rows.
      .ComputeControlSize 3, 4, sWidth, sHeight
      .MonthColumns = 4
      .MonthRows = 3  '
   End With

   ' Resize the control using the values from the method.
   Me.Width = MonthView1.Left + sWidth + 500
   Me.Height = MonthView1.Top + sHeight + 500
End Sub