473,804 Members | 2,755 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Resize Panel at runtime?

How would I go about resizing a panel control using a mouse at runtime?
Nov 20 '05 #1
2 5823
Hi Kevin,

It are no panels however labels, when you try this you understand very eays
in my opinion how to do it with panels.

It needs nothing just open a new form project delete all the code and past
this in.

I hope this helps?

Cor

Public Class Form1
Inherits System.Windows. Forms.Form
Public Sub New()
MyBase.New()
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Disp ose()
End If
End If
MyBase.Dispose( disposing)
End Sub
Private components As System.Componen tModel.IContain er
Private WithEvents Label1 As New System.Windows. Forms.Label
Private WithEvents Label2 As New System.Windows. Forms.Label
Private mouseX, mouseY As Integer
Private arLabels() As Label
Dim myMousedown As String
Private Sub Form1_Load(ByVa l sender As Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
Me.ClientSize = New System.Drawing. Size(400, 400)
Label1.Name = "Label1"
Label2.Name = "Label2"
arLabels = New Label() {Label1, Label2}
Dim lblY As Integer = 100
For Each Lbl As Label In arLabels
Lbl.Location = New System.Drawing. Point(100, lblY)
Lbl.ForeColor = Color.Red
Lbl.BackColor = Color.Transpare nt
Lbl.TextAlign = ContentAlignmen t.MiddleCenter
Lbl.Text = Lbl.Location.X. ToString & "." &
Lbl.Location.Y. ToString
AddHandler Lbl.MouseDown, AddressOf Label_MouseDown
AddHandler Lbl.MouseUp, AddressOf Label_MouseUp
AddHandler Lbl.MouseMove, AddressOf Label_MouseMove
lblY += 30
Me.Controls.Add (Lbl)
Next
End Sub
Private Sub Label_MouseDown (ByVal sender As Object, ByVal _
e As System.Windows. Forms.MouseEven tArgs)
Dim lbl As Label = DirectCast(send er, Label)
myMousedown = lbl.Name
lbl.BringToFron t()
mouseX = Cursor.Position .X - lbl.Location.X
mouseY = Cursor.Position .Y - lbl.Location.Y
lbl.Cursor = Cursors.Hand
End Sub
Private Sub Label_MouseUp(B yVal sender As Object, ByVal e As _
System.Windows. Forms.MouseEven tArgs)
Dim lbl As Label = DirectCast(send er, Label)
myMousedown = ""
lbl.Cursor = Cursors.Default
End Sub
Private Sub Label_MouseMove (ByVal sender As Object, ByVal e _
As System.Windows. Forms.MouseEven tArgs)
Dim lbl As Label = DirectCast(send er, Label)
Static LastCursor As Point
Dim NowCursor As Point = New Point(Cursor.Po sition.X,
Cursor.Position .Y)
If Point.op_Inequa lity(NowCursor, LastCursor) Then
If myMousedown = lbl.Name Then
lbl.Location = New System.Drawing. Point(Cursor.Po sition.X _
- mouseX, Cursor.Position .Y - mouseY)
End If
LastCursor = Cursor.Position
lbl.Text = lbl.Location.X. ToString & "." &
lbl.Location.Y. ToString
End If
End Sub
End Class
///
Nov 20 '05 #2
* "Kevin L" <no_spam@not_re al_email.com> scripsit:
How would I go about resizing a panel control using a mouse at runtime?


<URL:http://divil.co.uk/net/articles/designers/hosting.asp>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
<URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1261
by: Kevin L | last post by:
Is there a way to allow a user to Resize Panel controls on a form at RunTime using the mouse?
2
3575
by: Christian Soltenborn | last post by:
Hi guys, I have a question to VB .NET: I add a Graphics object to a panel and use a bunch of DrawLine methods etc (it's really nice and convenient). But: As soon as I send my form (which contains the panel) to the task bar and get it back, the graphics are gone. I guess that I need to add an event handler to the pane (or the form?), but which event do I have to handle? And which method do I call on the panel to get it repainted?...
2
9468
by: Carl Gilbert | last post by:
Hi I am looking for either a component or technique to allow me to do the following: * Provide a panel with a background image * Resize the image to best fit the panel to maintain aspect ratio * Provide white (or other color) borders at the sides or the top/bottom The last point would be used to allow users to resize the panel to any ratio
2
3964
by: timnels | last post by:
I have been able to execute Notepad.exe in a Panel (set to Dock.Fill) on a Windows Form, like: ProcessStartInfo psi = new ProcessStartInfo("notepad"); p = Process.Start(psi); p.WaitForInputIdle(); SetParent(p.MainWindowHandle, uiAppPanel.Handle); ShowWindow(p.MainWindowHandle, (int)ShowCommands.SW_MAXIMIZE); int style = GetWindowLong(p.MainWindowHandle, GWL_STYLE); SetWindowLong(p.MainWindowHandle, GWL_STYLE, style & ~WS_CAPTION);
4
3202
by: Russ Green | last post by:
I have a VB.NET app that uses lots of forms which I am loading into a panel cotrol using..... Me.pnlMain.Controls.Clear() frm.TopLevel = False frm.WindowState = FormWindowState.Maximized frm.Dock = DockStyle.Fill frm.Anchor = AnchorStyles.Left + AnchorStyles.Right + AnchorStyles.Top + AnchorStyles.Bottom
4
2901
by: =?Utf-8?B?bGpsZXZlbmQy?= | last post by:
I have a situation where I need to display a form in a panel. Everything works great except if the form is maximized and the panel's size changes. In this case the maximized form's bounds do not change. I tried updating the form's Bounds property in the panel's SizeChanged event but this does not work because the Bounds property seems to be ignored until the form is restored to the normal state. I also tried using the form's...
3
4173
by: Jeffrey Walton | last post by:
Hi All, I have a horizontal Splitter, for which I would like the top panel to remain 20 pixels in height. I do this because I have a containter on it, and I overide the OnPaint method. It is being painted as a band similar to that of Disk Defragmentor. Any ideas on how to disable a Splitter panel from being resized? I've locked the controls (it stops me from resizing it at design time); I've set SplitterFixedPanel = Panel1 ; and I've...
0
1282
by: rhandoo | last post by:
Hi, I have issue regarding resizing the form on runtime. Consider the following scenario, I have Winform with three panels panel-1 ( docked TOP) panel-2 ( docked Bottom) panel-3 ( docked Fill) On panel-1 I have two button btn_Show & btn_Hide
1
3683
by: hdivecha | last post by:
i have make a jtree program in java and if the node is circle then the circle can be shown in frame and i have to resize it with slider . plz help me i have done the tree program bt how to get selected node means its circle of any thing else i can't get it .. someone plz help me i have attached my program with this import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener;
0
10568
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10323
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10311
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10074
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9138
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7613
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5516
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4292
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.