Tab Control Page Not Responding Fast Enough
-
I have a CustomerInfo form which is an Mdi form to the main form. The CustomerInfo form a has TabControl with 4 TabPages on it. From the Main form CustomerInfo CI = new CustomerInfo(); In the form constructor event i have the following pseudeocode LoadGeneralTab() LoadOrderTab() LoadInvoiceTab() LoadPayHistoryTab() Each of these functions loads several Datagrids with information. Then from the main form CI.MdiParent = this; CI.Show(); The CustomerInfo form shows up as expected and all is good. But when I click on the orderTab or invoiceTab or the payHistoryTab it takes a long time to switch over to it. And the speed of the switch seems to be the amount of information contained in the datagrid views. What I don't understand is why this is happening as it seems to me that all the grids have been populated with information in the constructor so what is taking so long to switch over. I have done this before and not had the same problem. And help would be appreciated.
-
I have a CustomerInfo form which is an Mdi form to the main form. The CustomerInfo form a has TabControl with 4 TabPages on it. From the Main form CustomerInfo CI = new CustomerInfo(); In the form constructor event i have the following pseudeocode LoadGeneralTab() LoadOrderTab() LoadInvoiceTab() LoadPayHistoryTab() Each of these functions loads several Datagrids with information. Then from the main form CI.MdiParent = this; CI.Show(); The CustomerInfo form shows up as expected and all is good. But when I click on the orderTab or invoiceTab or the payHistoryTab it takes a long time to switch over to it. And the speed of the switch seems to be the amount of information contained in the datagrid views. What I don't understand is why this is happening as it seems to me that all the grids have been populated with information in the constructor so what is taking so long to switch over. I have done this before and not had the same problem. And help would be appreciated.
Member 2256533 wrote:
And the speed of the switch seems to be the amount of information contained in the datagrid views
Doesn't that answer your question. That implies you need to look closer to how the data is retrieved. May be you need to optimize your query. It is kinda hard to tell without looking at the code.
Yusuf May I help you?
-
Member 2256533 wrote:
And the speed of the switch seems to be the amount of information contained in the datagrid views
Doesn't that answer your question. That implies you need to look closer to how the data is retrieved. May be you need to optimize your query. It is kinda hard to tell without looking at the code.
Yusuf May I help you?
No not really, It does take some time for the CustomerInfo form to show up, and I assume that is because it does take time to load all the information on each of the tabs. But once the CustomerInfo form is displayed all the information should be loaded. So switching between tab pages should be quick. But it seems that the tabs are being reloaded everytime I switch over to them.
-
No not really, It does take some time for the CustomerInfo form to show up, and I assume that is because it does take time to load all the information on each of the tabs. But once the CustomerInfo form is displayed all the information should be loaded. So switching between tab pages should be quick. But it seems that the tabs are being reloaded everytime I switch over to them.
I guess the Controls (DGVs) that haven't been visible yet (those not on the first tab page) still haven't been rendered at all; so clicking on a tab will first cause the DGV to be actually created (including its Handle property), then the data being loaded into it. You could force this to happen sooner, IIRC reading Control.Handle suffices to make sure it really exists. Of course adding this to your Form.Load (or Shown) event will postpone its rendering of everything, including the first tab. A better way to handle the situation could be this, and I would recommend it anyway whenever the database accesses might take more than a second: - launch a thread to access the database, do not touch the Controls from that thread; - in the mean time, make sure all Controls really exist (Handle!); - when the database thread is done, make it signal the GUI thread and start showing the data. A BackgroundWorker would be good, having the DB stuff in its DoWork and the show-in-GUI stuff in its RunWorkercompleted handler. :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
-
I have a CustomerInfo form which is an Mdi form to the main form. The CustomerInfo form a has TabControl with 4 TabPages on it. From the Main form CustomerInfo CI = new CustomerInfo(); In the form constructor event i have the following pseudeocode LoadGeneralTab() LoadOrderTab() LoadInvoiceTab() LoadPayHistoryTab() Each of these functions loads several Datagrids with information. Then from the main form CI.MdiParent = this; CI.Show(); The CustomerInfo form shows up as expected and all is good. But when I click on the orderTab or invoiceTab or the payHistoryTab it takes a long time to switch over to it. And the speed of the switch seems to be the amount of information contained in the datagrid views. What I don't understand is why this is happening as it seems to me that all the grids have been populated with information in the constructor so what is taking so long to switch over. I have done this before and not had the same problem. And help would be appreciated.