about refresh UI !
I have a form which contains one tab contol with 开发者_JAVA百科3 tabs. How do I refresh only one tab page in the form with a backgroundworker thread and not refresh the other tabs?
Here is how to update a specific tab page in a tabcontrol:
private delegate void RefreshTabPageDelegate(int tabPage);
public static void RefreshTabPageThreadSafe(int tabPage)
{
if (tabControl.InvokeRequired)
{
tabControl.Invoke(new RefreshTabPageDelegate(RefreshTabPageThreadSafe), new object[] { tabPage });
}
else
{
if(tabControl.TabPages.Count > tabPage)
{
tabControl.TabPages[tabPage].Refresh();
}
}
}
Call it like this:
// thread-safe equivalent of
// tabControl.TabPage[1].Refresh();
RefreshTabPageThreadSafe(1);
精彩评论