Tab page issues
-
Hi, my problem is that I have a tab control, consisting of 4 tab pages and 4 user controls, 1 user control on each tab page. I would like to call the event method tabcontrol.selectedindex changed to load the data into the user control when the user clicks on the form, and not immediately when the selected index is changed. I need this because when certain users open the application the application will hide/remove a tab page if the user does not have access to that particular page. Upon removal, visual studio.net sets the selected index to the page index immediately before the one being removed. My loading of data was originally located within the load method of the user control itself, but this is causing my application to lag at startup when I need to remove a tabpage because it is loading that page when I remove the tabpage. My code currently looks like eg.: Public Sub tcCompany_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tc_Company.SelectedIndexChanged Select Case UCase(Me.tc_Company.SelectedTab.Name) Case "TP_COMPANYNOTES" 'checks to see if user clicked the notes page If Me.tcmediator.p_ucNotes.comb_companyName.Items.Count <= 0 Then 'checks if combo has data Call Me.tcmediator.p_ucNotes.userClickedForm() 'loads data End If Case "TP_COMPANYCREDIT" 'checks to see if user clicked the credit page If Me.tcmediator.p_ucCredit.comb_companyName.Items.Count <= 0 Then 'checks if combo has data Call Me.tcmediator.p_ucCredit.userClickedForm() 'loads data End If end select end sub Thanks for the help eatwork
-
Hi, my problem is that I have a tab control, consisting of 4 tab pages and 4 user controls, 1 user control on each tab page. I would like to call the event method tabcontrol.selectedindex changed to load the data into the user control when the user clicks on the form, and not immediately when the selected index is changed. I need this because when certain users open the application the application will hide/remove a tab page if the user does not have access to that particular page. Upon removal, visual studio.net sets the selected index to the page index immediately before the one being removed. My loading of data was originally located within the load method of the user control itself, but this is causing my application to lag at startup when I need to remove a tabpage because it is loading that page when I remove the tabpage. My code currently looks like eg.: Public Sub tcCompany_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tc_Company.SelectedIndexChanged Select Case UCase(Me.tc_Company.SelectedTab.Name) Case "TP_COMPANYNOTES" 'checks to see if user clicked the notes page If Me.tcmediator.p_ucNotes.comb_companyName.Items.Count <= 0 Then 'checks if combo has data Call Me.tcmediator.p_ucNotes.userClickedForm() 'loads data End If Case "TP_COMPANYCREDIT" 'checks to see if user clicked the credit page If Me.tcmediator.p_ucCredit.comb_companyName.Items.Count <= 0 Then 'checks if combo has data Call Me.tcmediator.p_ucCredit.userClickedForm() 'loads data End If end select end sub Thanks for the help eatwork
Why not load your control when it becomes visible for the first time ? Christian Graus - Microsoft MVP - C++
-
Why not load your control when it becomes visible for the first time ? Christian Graus - Microsoft MVP - C++
Hi Christian, thank you for your input, I can't load the control during the load method of the control because the control on the 4th tab page loads immediately after deleting the 5th tab page, because the tab control automatically sets the selected index to the index of the control...not sure how to explain this, but if you delete tab page 5, then the tab control within visual studio will set the selected index to tab 4 upon loading the tab control. when that happens tab 4's load method will execute causing the loading of the form to be an extra 3 seconds slower than it needs to be. Not too sure if that answers your question/answer. or if I am way off base could you explain your solution a little more please? thank you. eatwork
-
Hi Christian, thank you for your input, I can't load the control during the load method of the control because the control on the 4th tab page loads immediately after deleting the 5th tab page, because the tab control automatically sets the selected index to the index of the control...not sure how to explain this, but if you delete tab page 5, then the tab control within visual studio will set the selected index to tab 4 upon loading the tab control. when that happens tab 4's load method will execute causing the loading of the form to be an extra 3 seconds slower than it needs to be. Not too sure if that answers your question/answer. or if I am way off base could you explain your solution a little more please? thank you. eatwork
No, I meant during the visible changed event. When it becomes visible. Christian Graus - Microsoft MVP - C++
-
No, I meant during the visible changed event. When it becomes visible. Christian Graus - Microsoft MVP - C++