kengkit
asked on
using MDIcontainer
hellow guys.. i got a form named "form_master" which "IsMdiContainer" = True
the following code is the way how i open another form in "form_master"
my question is: How do i prevent duplicated "form_sales" being open?
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----
Public Class form_master
Dim sales_form As form_sales
Private Sub button_1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_POS.Click
sales_form = New form_sales()
sales_form.MdiParent = Me
sales_form.Show()
End Sub
End Class
the following code is the way how i open another form in "form_master"
my question is: How do i prevent duplicated "form_sales" being open?
--------------------------
Public Class form_master
Dim sales_form As form_sales
Private Sub button_1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_POS.Click
sales_form = New form_sales()
sales_form.MdiParent = Me
sales_form.Show()
End Sub
End Class
ASKER
To: Idle_Mind
how come i still can open duplicated form althought i used your code exactly?
The application doen't stop even I put the breakpoint at "If sales_form Is Nothing"
why?? (I was using visual studio .net 2005
Private Sub button_1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_POS.Click
If sales_form Is Nothing Then (breakpoint)
sales_form = New form_sales()
sales_form.MdiParent = Me
sales_form.Show()
End If
If sales_form.WindowState = FormWindowState.Minimized Then
sales_form.WindowState = FormWindowState.Normal
End If
sales_form.Activate()
End Sub
how come i still can open duplicated form althought i used your code exactly?
The application doen't stop even I put the breakpoint at "If sales_form Is Nothing"
why?? (I was using visual studio .net 2005
Private Sub button_1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_POS.Click
If sales_form Is Nothing Then (breakpoint)
sales_form = New form_sales()
sales_form.MdiParent = Me
sales_form.Show()
End If
If sales_form.WindowState = FormWindowState.Minimized Then
sales_form.WindowState = FormWindowState.Normal
End If
sales_form.Activate()
End Sub
ASKER
I found tat my application doesn't recognize my changed code...
For an instance..
Private Sub Button5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button5.Click
MsgBox("Hellow")
End Sub
The message box doesn't pop up when i click button5
For an instance..
Private Sub Button5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button5.Click
MsgBox("Hellow")
End Sub
The message box doesn't pop up when i click button5
Try deleting the "bin" subfolder in your project and running it again.
ASKER
all right.. now the problem is..
sales_form doesn't pop up.... unless i changed the code
from "If sales_form Is Nothing Then" to "If sales_form Is Nothing = False Then"
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- --------
Public Class form_master
Private WithEvents sales_form As New form_sales
Private Sub sales_form_FormClosed(ByVa l sender As Object, ByVal e As System.Windows.Forms.FormC losedEvent Args) Handles sales_form.FormClosed
sales_form = Nothing
End Sub
Private Sub ToolStripButton1_Click_1(B yVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
If sales_form Is Nothing = False Then
sales_form = New form_sales()
sales_form.MdiParent = Me
sales_form.Show()
End If
If sales_form.WindowState = FormWindowState.Minimized Then
sales_form.WindowState = FormWindowState.Normal
End If
sales_form.Activate()
End Sub
End Class
sales_form doesn't pop up.... unless i changed the code
from "If sales_form Is Nothing Then" to "If sales_form Is Nothing = False Then"
--------------------------
Public Class form_master
Private WithEvents sales_form As New form_sales
Private Sub sales_form_FormClosed(ByVa
sales_form = Nothing
End Sub
Private Sub ToolStripButton1_Click_1(B
If sales_form Is Nothing = False Then
sales_form = New form_sales()
sales_form.MdiParent = Me
sales_form.Show()
End If
If sales_form.WindowState = FormWindowState.Minimized Then
sales_form.WindowState = FormWindowState.Normal
End If
sales_form.Activate()
End Sub
End Class
You're using VB.Net 2005 right?
Try:
If IsNothing(sales_form) Then
sales_form = New form_sales()
sales_form.MdiParent = Me
sales_form.Show()
End If
Try:
If IsNothing(sales_form) Then
sales_form = New form_sales()
sales_form.MdiParent = Me
sales_form.Show()
End If
ASKER
Yup.. i'm using VS.net 2005 (VB)
i tried ur code oledi.. but the problem is existed
i tried ur code oledi.. but the problem is existed
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Public Class form_master
Private WithEvents sales_form As New form_sales
Private Sub button_1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_POS.Click
If sales_form Is Nothing Then
sales_form = New form_sales()
sales_form.MdiParent = Me
sales_form.Show()
End If
If sales_form.WindowState = FormWindowState.Minimized Then
sales_form.WindowState = FormWindowState.Normal
End If
sales_form.Activate()
End Sub
Private Sub sales_form_FormClosed(ByVa
sales_form = Nothing
End Sub
End Class