Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,368 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have a form with a tabcontrol with two tabPage. Each tabPage has a graphic. I would like that as soon as I load the form, the tabPage1 graphic is loaded automatically.
In the code below, where would the error be, because it does not load graph 1 automatically. It only works if you click on tabPage2 and then go back to tabPage1. There the graph is drawn. I couldn't find the error.
Private Sub TabControl1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles TabControl1.SelectedIndexChanged
If TabControl1.SelectedTab Is TabPage1 Then
' Load the graphic to TabPage1 tab
LoadChart1()
ElseIf TabControl1.SelectedTab Is TabPage2 Then
' Load the graphic to TabPage2 tab
LoadChart2()
End If
End Sub
Thanks
Try something like this:
Private Sub Form_Load(sender As Object, e As EventArgs) Handles Me.Load
LoadCurrentChart()
End Sub
Private Sub TabControl1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles TabControl1.SelectedIndexChanged
LoadCurrentChart()
End Sub
Sub LoadCurrentChart()
If TabControl1.SelectedTab Is TabPage1 Then
' Load the graphic to TabPage1 tab
LoadChart1()
ElseIf TabControl1.SelectedTab Is TabPage2 Then
' Load the graphic to TabPage2 tab
LoadChart2()
End If
End Sub