输入特定标签页后,我的应用程序应该重新调整应用程序窗口的大小。但是我似乎无法找到可行的解决方案。
这在VS 2010和VB.NET Windows窗体中。我在一个tabcontrol上有3个tabpage。
Private Sub TabControl1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
If TabControl1.TabPages(1).Focused = True Then
Me.Size = New System.Drawing.Size(369, 216) // Resizes Form
ElseIf TabControl1.TabPages(2).Focused = True Then
Me.Size = New System.Drawing.Size(788, 580) // Resizes Form
End If
End Sub
执行此命令时,它实际上不执行任何操作,但在IDE中没有错误。应该根据我单击的选项卡将表格的大小调整为369、216或788、580。
我已经尝试过SelectedTab方法,但是没有运气:
If TabControl1.SelectedTab = TabPage1 Then
...
End If
这是我从该代码中得到的错误:
Operator '=' is not defined for types 'System.Windows.Forms.TabPage' and 'System.Windows.Forms.TabPage'.
答案 0 :(得分:0)
您应该使用选定的标签进行比较,而不要关注重点事件。
Private Sub TabControl1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
If TabControl1.SelectedTab Is TabPage1 Then
Me.Size = New System.Drawing.Size(369, 216) // Resizes Form
ElseIf TabControl1.SelectedTab Is TabPage2 Then
Me.Size = New System.Drawing.Size(788, 580) // Resizes Form
End If
End Sub