TabPage在插入新的Tab时清空

时间:2019-07-15 08:24:55

标签: c# .net winforms

我整理了一些代码,在Winforms应用程序中添加了一个新选项卡。新标签页已插入,但我的页面现在空白。我尝试使用refresh命令,但似乎无法走得更远。

  private void tabControl1_MouseDown(object sender, MouseEventArgs e)
  {
     var lastIndex = this.tabControl1.TabCount - 1;
     Point mouseDownLocation = new Point(e.X, e.Y);

   if(this.tabControl1.GetTabRect(lastIndex).Contains(mouseDownLocation))
   {
       this.tabControl1.TabPages.Insert(lastIndex, tabPage2);
       this.tabControl1.SelectedIndex = lastIndex;
       tabControl1.Refresh();
   }
 }

PIC1:table before new tab PIC2:table vanishes after new tab is added

0 个答案:

没有答案