In C# Windows Forms application, I have problem as follows:
- I have tab control with 5 tabs
- On each tab, I have a
DataGridView(control type is not important and you can consider a panel instead) - After loading the form, when I get
DataGridViewwidth from inactive tab (#5), it is 500 (wrong value) - When I activate tab #5, then get
DataGridViewwidth as 700 (which is the correct value)
Question
As I found, objects in hidden situation cannot return correct value in relation to visual parameters. How can I force application to set its correct state and return correct value in an identical situation as mentioned above?
Why I need control property when it is hidden or out of view?
In each tab, there is a custom DGV (Ces.WinForm.UI) and when user assign DataSource, a Load Screen will appeare in front of DGV to prevent user for any unnecessary click to raise any event related to DGV. So, When selected item in ComboBox changes by user, then all DGVs must be updated with new value selected in ComboBox. In this situation, while no tab is selected, cause to show Load Screen in wrong position & size.
I tried to perform layout then repaint object as follow in Resize event of tab control (but this did not work):
private void tabControl1_Resize(object sender, EventArgs e)
{
foreach (TabPage t in tabControl1.TabPages)
{
t.PerformLayout();
t.Refresh();
t.Invalidate();
}
}
design time, form size is small but inrun timemust bemaximize. Because of that I put my solution onresizeevent of tab control.