Moveable toolbar

F

Flashster

How do I create a moveable toolbar that can be docked on a windows form?.
I'm using vb .net (2002).

I have added the toolbar item to the windows form, but I cannot see a way of
making it draggable, nor adding the classic 'dragging bar' on the left hand
side of the toolbar?

(sorry, I'm a new to VB .net)

Flashster
 
C

Cor Ligthert [MVP]

Flashter,

Why you take difficult parts first when you are new to VBNet. As most answer
on this that they have a lot of experience in other language. Than I can
give you the answers direct. Try first the usual things, than the answer on
this kind of problems will come automatically.

Although that there are thirth party controls, by instance at syncfusion

http://www.syncfusion.com/Products/Studio.aspx

If it is just replacing it on your form look than add the dock property of
the toolbar

I hope this helps,

Cor
 
F

Flashster

I should have said that although I am not that familiar with VB .net, I am
familiar with programming generally.

I know of third part solutions to do this - but is there any examples of how
to have a floating toolbar in a windows form in VB .net?

As far as I can see the 'dock' property allows you to fix the bar in a
position within the form, but how do you allow the user to actually drag the
toolbar to where they want?
 
P

Peter Proost

Hi,

set the toolbars dock property to false and try this code:

Private dragging As Boolean
Private beginX, beginY As Integer

Private Sub ToolBar1_MouseDown(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) Handles ToolBar1.MouseDown

dragging = True
beginX = e.X
beginY = e.Y

End Sub

Private Sub ToolBar1_MouseMove(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) Handles ToolBar1.MouseMove
If dragging = True Then
ToolBar1.Location = New Point(ToolBar1.Location.X + e.X -
beginX, ToolBar1.Location.Y + e.Y - beginY)
Me.Refresh()
End If
End Sub

Private Sub ToolBar1_MouseUp(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) Handles ToolBar1.MouseUp

dragging = False

End Sub

hth Greetz Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top