By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,641 Members | 1,446 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,641 IT Pros & Developers. It's quick & easy.

Move a panel......it's possible?

P: n/a
i hope you can help me!
It's possible create a moveable panel in vb.net?
Click with mouse over it and move it everywhere!?!?
It's possible?
thank u!
Nov 21 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Handle the panel's mousedown and mousemove events. Change the panel's
Location when the mouse is down.

See the application after my signature

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
Public Class Form1

Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()

MyBase.New()

'This call is required by the Windows Form Designer.

InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.

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

'Required by the Windows Form Designer

Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer.

'Do not modify it using the code editor.

Friend WithEvents Panel1 As System.Windows.Forms.Panel

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

Me.Panel1 = New System.Windows.Forms.Panel

Me.SuspendLayout()

'

'Panel1

'

Me.Panel1.BackColor = System.Drawing.Color.Red

Me.Panel1.Location = New System.Drawing.Point(56, 80)

Me.Panel1.Name = "Panel1"

Me.Panel1.TabIndex = 0

'

'Form1

'

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

Me.ClientSize = New System.Drawing.Size(368, 310)

Me.Controls.Add(Me.Panel1)

Me.Name = "Form1"

Me.Text = "Form1"

Me.ResumeLayout(False)

End Sub

#End Region

Private _mousedown As Boolean

Private _mousepos As Point

Private Sub Panel1_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseDown

_mousedown = True

_mousepos = New Point(e.X, e.Y)

End Sub

Private Sub Panel1_MouseMove(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseMove

If _mousedown Then

Me.Panel1.Location = PointToClient(Me.Panel1.PointToScreen(New Point(e.X -
_mousepos.X, e.Y - _mousepos.Y)))

End If

End Sub

Private Sub Panel1_MouseUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseUp

_mousedown = False

End Sub

End Class

"tranky" <NO****@THANKY.YOU> wrote in message
news:Xc*******************@news4.tin.it...
i hope you can help me!
It's possible create a moveable panel in vb.net?
Click with mouse over it and move it everywhere!?!?
It's possible?
thank u!

Nov 21 '05 #2

P: n/a
"tranky" <NO****@THANKY.YOU> schrieb:
It's possible create a moveable panel in vb.net?
Click with mouse over it and move it everywhere!?!?


<URL:http://dotnet.mvps.org/dotnet/samples/misc/XmlSerialization.zip>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #3

P: n/a
Tranky,

Althought this is not about panels is the principle the same

http://www.windowsformsdatagridhelp....1-47ef665ea0c2

I hope this helps,

Cor

"tranky" <NO****@THANKY.YOU> schreef in bericht
news:Xc*******************@news4.tin.it...
i hope you can help me!
It's possible create a moveable panel in vb.net?
Click with mouse over it and move it everywhere!?!?
It's possible?
thank u!

Nov 21 '05 #4

P: n/a
hi cor, i tried your example, but there's a problem:
when i move panel over form dialog, it become hidden and i can't reach it
anymore!
there's a solution?? It's possible move the panel over form dialog and see
it?
I don't speak well english, i hope you understand me.
thank you.
Nov 21 '05 #5

P: n/a
for see it over the form dialog you think i must use another form? Panel is
not the right way?

and then: Is possible to block panel when it arrive to the border of form?
in you example, when i move panel over form border, it's become hidden!
Nov 21 '05 #6

P: n/a
Tranky,

I don't know if you mean the

http://msdn.microsoft.com/library/de...fronttopic.asp

However, my sample is just a sample how to start. Getting the borders and
all those things is forever a terrible thing to do. And the most worse, you
can almost not debug this sample.

Cor

"tranky" <NO****@THANKY.YOU> schreef in bericht
news:n%******************@news3.tin.it...
hi cor, i tried your example, but there's a problem:
when i move panel over form dialog, it become hidden and i can't reach it
anymore!
there's a solution?? It's possible move the panel over form dialog and see
it?
I don't speak well english, i hope you understand me.
thank you.

Nov 21 '05 #7

P: n/a
You would have to verify that the panel doesn't go outside of the form
manually. It'd be pretty simple to check that the location was always inside
the form surface.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"tranky" <NO****@THANKY.YOU> wrote in message
news:j3******************@news3.tin.it...
for see it over the form dialog you think i must use another form? Panel
is not the right way?

and then: Is possible to block panel when it arrive to the border of form?
in you example, when i move panel over form border, it's become hidden!

Nov 21 '05 #8

P: n/a
thanks for the help to all!
Nov 21 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.