Hi Herfried,
here is some cut and paste code for an mdi form and 2 forms with
identical buttons that reproduces the issue.
users can keep more than one form open at a time.
form2 is the mdi parent, form1 is the child
the buttons work fine if only one form is open, but dies if there are
more than one open.
look forward to your response
Edwinah63
*************mdi parent **************
Public Class Form2
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
Friend WithEvents Button1 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.Panel1 = New System.Windows.Forms.Panel
Me.Button1 = New System.Windows.Forms.Button
Me.Panel1.SuspendLayout()
Me.SuspendLayout()
'
'Panel1
'
Me.Panel1.Controls.Add(Me.Button1)
Me.Panel1.Location = New System.Drawing.Point(5, 382)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(148, 37)
Me.Panel1.TabIndex = 1
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(21, 7)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(105, 22)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Button1"
'
'Form2
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(439, 451)
Me.Controls.Add(Me.Panel1)
Me.IsMdiContainer = True
Me.Name = "Form2"
Me.Text = "Form2"
Me.Panel1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim f1 As New Form1
f1.MdiParent = Me
f1.Show()
Dim f2 As New Form1
f2.MdiParent = Me
f2.Show()
End Sub
End Class
****** now for the child form
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 TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents btnAdd As System.Windows.Forms.Button
Friend WithEvents btnEdit As System.Windows.Forms.Button
Friend WithEvents btnSave As System.Windows.Forms.Button
Friend WithEvents btnReset As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.btnAdd = New System.Windows.Forms.Button
Me.btnEdit = New System.Windows.Forms.Button
Me.btnSave = New System.Windows.Forms.Button
Me.btnReset = New System.Windows.Forms.Button
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.SuspendLayout()
'
'btnAdd
'
Me.btnAdd.Location = New System.Drawing.Point(17, 39)
Me.btnAdd.Name = "btnAdd"
Me.btnAdd.Size = New System.Drawing.Size(83, 23)
Me.btnAdd.TabIndex = 0
Me.btnAdd.Text = "&Add"
'
'btnEdit
'
Me.btnEdit.Location = New System.Drawing.Point(17, 73)
Me.btnEdit.Name = "btnEdit"
Me.btnEdit.Size = New System.Drawing.Size(80, 22)
Me.btnEdit.TabIndex = 1
Me.btnEdit.Text = "&Edit"
'
'btnSave
'
Me.btnSave.Location = New System.Drawing.Point(18, 114)
Me.btnSave.Name = "btnSave"
Me.btnSave.Size = New System.Drawing.Size(78, 21)
Me.btnSave.TabIndex = 2
Me.btnSave.Text = "&Save"
'
'btnReset
'
Me.btnReset.Location = New System.Drawing.Point(18, 150)
Me.btnReset.Name = "btnReset"
Me.btnReset.Size = New System.Drawing.Size(80, 22)
Me.btnReset.TabIndex = 3
Me.btnReset.Text = "Rese&t"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(142, 93)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(138, 20)
Me.TextBox1.TabIndex = 4
Me.TextBox1.Text = ""
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.btnReset)
Me.Controls.Add(Me.btnSave)
Me.Controls.Add(Me.btnEdit)
Me.Controls.Add(Me.btnAdd)
Me.Name = "Form1"
Me.Text = "Hotkeys!!"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
Me.TextBox1.Text = "Add"
Config("A")
End Sub
Private Sub btnEdit_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnEdit.Click
Me.TextBox1.Text = "Edit"
Config("E")
End Sub
Private Sub btnSave_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnSave.Click
Me.TextBox1.Text = "Save"
Config("R")
End Sub
Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnReset.Click
'clear
Me.TextBox1.Text = ""
Config("R")
End Sub
Private Sub Config(ByVal x As String)
Select Case x
Case "A", "E"
btnAdd.Enabled = False
btnEdit.Enabled = False
btnSave.Enabled = True
Case "R"
btnAdd.Enabled = True
btnEdit.Enabled = True
btnSave.Enabled = False
End Select
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Config("R")
End Sub
End Class