开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜