TopicLinkClick的代码如下,该代码是根据导航栏修改的,导航栏是没有问题的,但任务栏不行,请教老师们解惑。谢谢!
Select Case e.Link.Name
Case "设备档案"
'' 获取选项卡控件
Dim tab As WinForm.TabControl = e.Form.Controls("TabControl1")
' 获取任务栏控件
Dim top As WinForm.TopicBar = e.Sender
' 检查是否已经存在相应的选项卡页签
Dim tabPageExists As Boolean = False
For i As Integer = 0 To tab.TabPages.Count - 1
If tab.TabPages(i).Name = top.Name Then
' 如果存在,设置选中的页签并标记存在
tab.SelectedIndex = i
tabPageExists = True
Exit For
End If
Next
If Not tabPageExists Then
' 如果选项卡页签不存在,检查是否已经存在相应的窗体
If Forms.Contains(top.Name) Then
' 如果窗体已存在,直接切换到对应选项卡
tab.TabPages.Add(top.Name, top.Name)
tab.SelectedIndex = tab.TabPages.Count - 1
' 停止窗体重绘,提高性能
e.Form.StopRedraw
tab.TabPages.Add(top.Name, top.Name)
Forms(top.Name).Open( - 1000, - 1500)
Forms(top.Name).BaseForm.TopLevel = False
Forms(top.Name).BaseForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
Forms(top.Name).BaseForm.Dock = System.Windows.Forms.DockStyle.Fill
Forms(top.Name).BaseForm.AutoScroll = True
tab.TabPages(top.Name).Controls.Add(F
orms(top.Name).BaseForm) tab.SelectedPage = tab.TabPages(top.Name)
BaseMainForm.Activate()
e.Form.ResumeRedraw
Else
' 如果窗体不存在,显示建设中的提示信息
MessageBox.Show("建设中……敬请期待!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
End If
End Select