Reputation: 89
I have 3 tabPages on tabControl and each tabPage have a pictureBox.
When i select a row in gridview it load images from files, and on selection i want refresh the 3 tabs with images. The problem is that pictureBox refresh only when i switch tabPage not when i change image. I tried to refresh, invalidate, or update controls but it dont work.
I find it:
"Controls contained in a TabPage are not created until the tab page is shown, and any data bindings in these controls are not activated until the tab page is shown."
How to solve that problem.
Upvotes: 0
Views: 1225
Reputation: 7689
Since the tab won't load the controls until it is selected, one common workaround is to force the focus on the tabs programatically.
The only drawback is that user will see a blink of screen, due to effect of visibility. In case you on't play with the visibility, user will see focus moving from tab to tab, which is much worse! :)
Upvotes: 0
Reputation: 26876
You can force-create your controls using reflection. For example
private void CreateControl(Control control)
{
var method = control.GetType().GetMethod("CreateControl", BindingFlags.Instance | BindingFlags.NonPublic);
method.Invoke(control, new object[] { true });
}
Upvotes: 0