I want to handle mousedown,mouseclick events for each panel within these nested splittercontainers.
What happens now is that only when I click on the splitter does the event get handled. If I click on any one of the panels, nothing happens! I can't figure this out... Thank you for any help. -Greg
Form1.vb
Imports SystemImports
System.DrawingImports
System.CollectionsImports
System.ComponentModelImports
System.Windows.FormsImports
System.DataImports
Microsoft.VisualBasicPublic
Class Form1 Inherits System.Windows.Forms.Form Public Sub New()InitializeComponent()
End Sub 'New<STAThread()> _
Shared Sub Main()Application.Run(
New Form1()) End Sub 'Main Private Sub splitContainer1_SplitterMoving(ByVal sender As System.Object, ByVal e As System.Windows.Forms.SplitterCancelEventArgs) Handles SplitContainerLeft.SplitterMoving ' As the splitter moves, change the cursor type.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.NoMoveVert
End Sub 'splitContainer1_SplitterMoving Private Sub splitContainer1_SplitterMoved(ByVal sender As System.Object, ByVal e As System.Windows.Forms.SplitterEventArgs) Handles SplitContainerLeft.SplitterMoved ' When the splitter stops moving, change the cursor back to the default.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default
End Sub 'splitContainer1_SplitterMovedPrivate Sub SplitContainerLeft_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles SplitContainerLeft.MouseDown
MessageBox.Show(
"splitcontainerLeft mousedown") End Sub Private Sub SplitContainerLeft_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClickMessageBox.Show(
"splitcontainerLeft mouseclick") End SubEnd
Class 'Form1
Form1.Designer.vb
<
Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _Partial
Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list.<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Thencomponents.Dispose()
End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer Friend WithEvents SplitContainerRight As System.Windows.Forms.SplitContainer Friend WithEvents SplitContainerLeft As System.Windows.Forms.SplitContainer Friend WithEvents SplitContainerMain As System.Windows.Forms.SplitContainer '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. '<System.Diagnostics.DebuggerStepThrough()> _ 'Private Sub InitializeComponent() ' components = New System.ComponentModel.Container ' Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font ' Me.Text = "Form2" 'End Sub Private Sub InitializeComponent() Me.SplitContainerMain = New System.Windows.Forms.SplitContainer Me.SplitContainerLeft = New System.Windows.Forms.SplitContainer Me.SplitContainerRight = New System.Windows.Forms.SplitContainer Me.SplitContainerMain.Panel1.SuspendLayout() Me.SplitContainerMain.Panel2.SuspendLayout() Me.SplitContainerMain.SuspendLayout() Me.SplitContainerLeft.SuspendLayout() Me.SplitContainerRight.SuspendLayout() Me.SuspendLayout() ' 'SplitContainerMain ' Me.SplitContainerMain.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.SplitContainerMain.Dock = System.Windows.Forms.DockStyle.Fill Me.SplitContainerMain.ForeColor = System.Drawing.SystemColors.Control Me.SplitContainerMain.Location = New System.Drawing.Point(0, 0) Me.SplitContainerMain.Name = "SplitContainerMain" ' 'SplitContainerMain.Panel1 ' Me.SplitContainerMain.Panel1.BackColor = System.Drawing.SystemColors.Control Me.SplitContainerMain.Panel1.Controls.Add(Me.SplitContainerLeft) Me.SplitContainerMain.Panel1.RightToLeft = System.Windows.Forms.RightToLeft.Yes Me.SplitContainerMain.Panel1MinSize = 30 ' 'SplitContainerMain.Panel2 ' Me.SplitContainerMain.Panel2.Controls.Add(Me.SplitContainerRight) Me.SplitContainerMain.Panel2MinSize = 20 Me.SplitContainerMain.Size = New System.Drawing.Size(292, 273) Me.SplitContainerMain.SplitterDistance = 129 Me.SplitContainerMain.SplitterIncrement = 10 Me.SplitContainerMain.SplitterWidth = 2 Me.SplitContainerMain.TabIndex = 0 Me.SplitContainerMain.Text = "SplitContainerMain" ' 'SplitContainerLeft ' Me.SplitContainerLeft.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.SplitContainerLeft.Dock = System.Windows.Forms.DockStyle.Fill Me.SplitContainerLeft.Location = New System.Drawing.Point(0, 0) Me.SplitContainerLeft.Name = "SplitContainerLeft" Me.SplitContainerLeft.Orientation = System.Windows.Forms.Orientation.Horizontal ' 'SplitContainerLeft.Panel1 ' Me.SplitContainerLeft.Panel1.RightToLeft = System.Windows.Forms.RightToLeft.Yes ' 'SplitContainerLeft.Panel2 ' Me.SplitContainerLeft.Panel2.RightToLeft = System.Windows.Forms.RightToLeft.Yes Me.SplitContainerLeft.Size = New System.Drawing.Size(129, 273) Me.SplitContainerLeft.SplitterDistance = 124 Me.SplitContainerLeft.SplitterWidth = 2 Me.SplitContainerLeft.TabIndex = 2 Me.SplitContainerLeft.Text = "SplitContainerLeft" ' 'SplitContainerRight ' Me.SplitContainerRight.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.SplitContainerRight.Dock = System.Windows.Forms.DockStyle.Fill Me.SplitContainerRight.ForeColor = System.Drawing.SystemColors.Control Me.SplitContainerRight.Location = New System.Drawing.Point(0, 0) Me.SplitContainerRight.Name = "SplitContainerRight" Me.SplitContainerRight.Orientation = System.Windows.Forms.Orientation.Horizontal ' 'SplitContainerRight.Panel1 ' Me.SplitContainerRight.Panel1.RightToLeft = System.Windows.Forms.RightToLeft.Yes ' 'SplitContainerRight.Panel2 ' Me.SplitContainerRight.Panel2.RightToLeft = System.Windows.Forms.RightToLeft.Yes Me.SplitContainerRight.Size = New System.Drawing.Size(161, 273) Me.SplitContainerRight.SplitterDistance = 124 Me.SplitContainerRight.TabIndex = 2 ' 'Form2 ' Me.ClientSize = New System.Drawing.Size(292, 273) Me.Controls.Add(Me.SplitContainerMain) Me.Name = "Form1" Me.Text = "Form1" Me.SplitContainerMain.Panel1.ResumeLayout(False) Me.SplitContainerMain.Panel2.ResumeLayout(False) Me.SplitContainerMain.ResumeLayout(False) Me.SplitContainerLeft.ResumeLayout(False) Me.SplitContainerRight.ResumeLayout(False) Me.ResumeLayout(False) End Sub 'InitializeComponentEnd
Class
form1.vb and form1.designer.vb code for 4 panel splitter container control .
VijayVeera
Fekih Mehdi
prasad_8104
first of all you can set your panels TAG or AccessibleName property to identify them...
and the code to handle the Mouse Down event for all
Private Sub PanelMouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles SplitContainer1.Panel1.MouseDown, SplitContainer1.Panel2.MouseDown, SplitContainer2.Panel1.MouseDown, SplitContainer2.Panel2.MouseDown Dim pnl As Panelpnl =
CType(sender, Panel)MsgBox(
"Clicked on" & pnl.Tag) End Subregards..
Ayhan
turczytj
Never mind. I was confused by the Panel text for each of the 4 parts. I have to add panels to each part of splittercontainer and handle those individual mouse events. Question. How would I handle all 4 panels with one event handler.
s