直接上代码:
Public Sub TooltripItemAdd()
Dim XTool As ToolStrip = Nothing
For Each tCtrl As Control In Me.CrystalReportViewer1.Controls
If TypeOf tCtrl Is ToolStrip Then
XTool = tCtrl
Continue For
End If
Next
Dim BtClose As New ToolStripButton
BtClose.Image = My.Resources.关闭1
BtClose.ImageScaling = ToolStripItemImageScaling.SizeToFit
BtClose.ToolTipText = "关闭报表"
BtClose.Margin = New System.Windows.Forms.Padding(15, 0, 0, 0)
AddHandler BtClose.Click, AddressOf Me.CRClosed
Dim BtSelect As New ToolStripButton
BtSelect.Image = My.Resources.搜索
BtSelect.ImageScaling = ToolStripItemImageScaling.SizeToFit
BtSelect.ToolTipText = "搜索"
BtSelect.Margin = New System.Windows.Forms.Padding(15, 0, 10, 0)
AddHandler BtSelect.Click, AddressOf Me.OpenSelect
'增加按钮
XTool.Items.Add(BtSelect)
XTool.Items.Add(BtClose)
XTool.Size = New System.Drawing.Size(200, 36)
'ToolStripItem 设定手动重新排列
XTool.AllowItemReorder = True
'调整显示顺序
XTool.Items.Insert(0, BtSelect)
'增加分割符
XTool.Items.Insert(12, New ToolStripSeparator())
End Sub