如何在vb.net中实现浮动工具栏???
请问各位大侠,怎样在vb.net 中实现浮动工具栏效果。
最好附上源码,谢谢指教!!!
解决问题马上结贴!
问题点数:40、回复次数:9Top
1 楼Ninputer(装配脑袋)回复于 2004-05-04 19:35:39 得分 4
如果你不怕等,Visual Basic 2005内置这个控件Top
2 楼zxhtgh(朱能文)回复于 2004-05-04 22:46:11 得分 0
第三方控件也可以,请写明其用法,最好有源代码!
Top
3 楼wgsnet(自由奔腾)回复于 2004-05-04 23:21:10 得分 5
第三方控件?
建议去``百度``搜索!!Top
4 楼gaosuote(gaosuote)回复于 2004-05-05 13:31:01 得分 6
用ActiveBar 2可以实现Top
5 楼ReinhardCao(ReinhardCao)回复于 2004-05-05 16:24:44 得分 12
用自己的代码实现也可以,不过有点简陋:
'Form1上有个ToolBar1
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim frm As New Form2(Me, Me.ToolBar1)
End Sub
Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
Dim Index As Integer = Me.ToolBar1.Buttons.IndexOf(e.Button) + 1
MsgBox("第" & Index & "个button被click")
End Sub
End Class
'Form2代码,是浮动的窗体,上面有个ContextMenu1
Public Class Form2
Inherits System.Windows.Forms.Form
Dim WithEvents m_ToolBar As ToolBar
Dim m_ParentForm As Form
Public Sub New(ByVal ParentForm As Form, ByVal Bar As ToolBar)
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
m_ParentForm = ParentForm
m_ToolBar = Bar
m_ToolBar.ContextMenu = Me.ContextMenu1
Me.m_ParentForm.AddOwnedForm(Me)
End Sub
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
MenuItem1.Checked = Not (MenuItem1.Checked)
If MenuItem1.Checked Then
m_ToolBar.Parent = Me
Me.Visible = True
Else
m_ToolBar.Parent = m_ParentForm
Me.Visible = False
End If
End Sub
End Class
Top
6 楼chenyu001(天使之恋)回复于 2004-05-05 22:12:46 得分 1
用ActiveBar 2把 太强大了Top
7 楼zxhtgh(朱能文)回复于 2004-05-08 20:15:19 得分 0
谢谢ReinhardCao(ReinhardCao) 和大家的帮助,我试一下!Top
8 楼zxhtgh(朱能文)回复于 2004-05-09 08:30:05 得分 0
请问ActiveBar 2有没有for .net 的版本Top
9 楼LoveEgg(我很菜)回复于 2004-05-09 09:48:54 得分 12
用Windows窗体实现的简单例子,希望对你有所帮助:
Form1是主窗体:
Public Class Form1
Inherits System.Windows.Forms.Form
Dim WithEvents frmToolBar As New Form2
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写 dispose 以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents Ftp1 As Dart.PowerTCP.Ftp.Ftp
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Me.Ftp1 = New Dart.PowerTCP.Ftp.Ftp(Me.components)
'
'Ftp1
'
Me.Ftp1.ClientDataPort = ""
'
'Ftp1.Connection
'
Me.Ftp1.Connection.Charset = "gb2312"
Me.Ftp1.Connection.DoEvents = False
Me.Ftp1.Editor = Me.Ftp1
Me.Ftp1.Password = ""
Me.Ftp1.Server = ""
Me.Ftp1.Username = ""
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.BackColor = System.Drawing.SystemColors.Control
Me.ClientSize = New System.Drawing.Size(416, 413)
Me.Name = "Form1"
Me.Text = "Form1"
Me.TransparencyKey = System.Drawing.Color.DimGray
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'显示浮动工具栏
frmToolBar.Show()
End Sub
'监视工具栏上的按钮的动作
Private Sub AddClicked() Handles frmToolBar.AddClick
MsgBox("Add")
End Sub
Private Sub OpenClicked() Handles frmToolBar.OpenClick
MsgBox("Open")
End Sub
Private Sub Form1_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
frmToolBar.Close()
End Sub
End Class
'Form2是浮动工具栏:
Public Class Form2
Inherits System.Windows.Forms.Form
'加了“Add”、“Open”两个按钮作为示例
Friend Event AddClick()
Friend Event OpenClick()
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写 dispose 以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents ToolBar1 As System.Windows.Forms.ToolBar
Friend WithEvents ToolBarButton1 As System.Windows.Forms.ToolBarButton
Friend WithEvents ToolBarButton2 As System.Windows.Forms.ToolBarButton
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.ToolBar1 = New System.Windows.Forms.ToolBar
Me.ToolBarButton1 = New System.Windows.Forms.ToolBarButton
Me.ToolBarButton2 = New System.Windows.Forms.ToolBarButton
Me.SuspendLayout()
'
'ToolBar1
'
Me.ToolBar1.Appearance = System.Windows.Forms.ToolBarAppearance.Flat
Me.ToolBar1.Buttons.AddRange(New System.Windows.Forms.ToolBarButton() {Me.ToolBarButton1, Me.ToolBarButton2})
Me.ToolBar1.Divider = False
Me.ToolBar1.Dock = System.Windows.Forms.DockStyle.Fill
Me.ToolBar1.DropDownArrows = True
Me.ToolBar1.Location = New System.Drawing.Point(0, 0)
Me.ToolBar1.Name = "ToolBar1"
Me.ToolBar1.ShowToolTips = True
Me.ToolBar1.Size = New System.Drawing.Size(351, 39)
Me.ToolBar1.TabIndex = 0
'
'ToolBarButton1
'
Me.ToolBarButton1.Text = "Add"
'
'ToolBarButton2
'
Me.ToolBarButton2.Text = "Open"
'
'Form2
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(351, 35)
Me.Controls.Add(Me.ToolBar1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
Me.Name = "Form2"
Me.ShowInTaskbar = False
Me.Text = "ToolBar"
Me.TopMost = True
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
Select Case e.Button.Text
Case "Add"
RaiseEvent AddClick()
Case "Open"
RaiseEvent OpenClick()
End Select
End Sub
End ClassTop




