emi_sastra
asked on
ACCESS MDICHILD VARIABLES OR PROPERTIES
Hi All,
I create a mdi parent and several mdi child forms.
I want to access mdi child form variables and properties.
Public Class Form3
Implements MdiChildForm
Private clsFormAuthority As clsFormAuthority
Public Sub New(ByVal clsFormAuthority As clsFormAuthority)
Me.InitializeComponent()
Me.clsFormAuthority = clsFormAuthority
End Sub
Private intMode As Int16 = ERV_GLOBAL.MB_VIEW
Public Property Mode() As Integer
Get
Return intMode
End Get
Set(ByVal value As Integer)
intMode = value
End Set
End Property
End Sub
How could I access :
1. clsFormAuthority
2. Mode Properties
Thank you.
I create a mdi parent and several mdi child forms.
I want to access mdi child form variables and properties.
Public Class Form3
Implements MdiChildForm
Private clsFormAuthority As clsFormAuthority
Public Sub New(ByVal clsFormAuthority As clsFormAuthority)
Me.InitializeComponent()
Me.clsFormAuthority = clsFormAuthority
End Sub
Private intMode As Int16 = ERV_GLOBAL.MB_VIEW
Public Property Mode() As Integer
Get
Return intMode
End Get
Set(ByVal value As Integer)
intMode = value
End Set
End Property
End Sub
How could I access :
1. clsFormAuthority
2. Mode Properties
Thank you.
You can also do this ass following
Dim child As Form3= Me.ActiveMDIChild
child.clsFormAuthority = *****
child.Mode = *****
for more reference please follow the urls:
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.activemdichild.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-2
http://p2p.wrox.com/vb-net-2002-2003-basics/56165-controlling-mdi-child-form-mdi-parent-panel.html
Dim child As Form3= Me.ActiveMDIChild
child.clsFormAuthority = *****
child.Mode = *****
for more reference please follow the urls:
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.activemdichild.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-2
http://p2p.wrox.com/vb-net-2002-2003-basics/56165-controlling-mdi-child-form-mdi-parent-panel.html
ASKER
Please my code.
If ERV_GLOBAL.Form_Active("Fo rm3", Me) Then
Dim frm As Form = Me.ActiveMdiChild
Me.ShowHideControl(intMode , clsFormAuthority)
Else
If clsFormAuthority.blnAccess Then
Dim Form3 As New Form3(clsFormAuthority)
Form3.MdiParent = Me
Form3.Show()
End If
End If
What should I do ?
Thank you.
If ERV_GLOBAL.Form_Active("Fo
Dim frm As Form = Me.ActiveMdiChild
Me.ShowHideControl(intMode
Else
If clsFormAuthority.blnAccess
Dim Form3 As New Form3(clsFormAuthority)
Form3.MdiParent = Me
Form3.Show()
End If
End If
What should I do ?
Thank you.
Change this line
Dim frm As Form = Me.ActiveMdiChild
to
Dim frm As Form3 = Me.ActiveMdiChild
I suppose this
Me.ShowHideControl(intMode , clsFormAuthority)
would be
Me.ShowHideControl(frm.int Mode, frm.clsFormAuthority)
Dim frm As Form = Me.ActiveMdiChild
to
Dim frm As Form3 = Me.ActiveMdiChild
I suppose this
Me.ShowHideControl(intMode
would be
Me.ShowHideControl(frm.int
ASKER
Hi CodeCruiser,
I've got compile error :
Error 1 'WindowsApplication1.Form3 .intMode' is not accessible in this context because it is 'Private'.
Error 2 'WindowsApplication1.Form3 .clsFormAu thority' is not accessible in this context because it is 'Private'.
Thank you.
I've got compile error :
Error 1 'WindowsApplication1.Form3
Error 2 'WindowsApplication1.Form3
Thank you.
Use "Mode" instead of "intMode".
For "clsFormAuthority", you'd need to change the access modifier to public. *This has already been mentioned!*
Change:
Private clsFormAuthority As clsFormAuthority
To:
Public clsFormAuthority As clsFormAuthority
For "clsFormAuthority", you'd need to change the access modifier to public. *This has already been mentioned!*
Change:
Private clsFormAuthority As clsFormAuthority
To:
Public clsFormAuthority As clsFormAuthority
ASKER
Could access to its property ?
Public Property Mode() As Integer
Get
Return intMode
End Get
Set(ByVal value As Integer)
intMode = value
End Set
End Property
Thank you.
Public Property Mode() As Integer
Get
Return intMode
End Get
Set(ByVal value As Integer)
intMode = value
End Set
End Property
Thank you.
ASKER
- Use "Mode" instead of "intMode".
Get it.
One more problem.
Private Sub btnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim frm As Form = Me.ActiveMdiChild
If Not IsNothing(frm) AndAlso TypeOf frm Is MdiChildForm Then
DirectCast(frm, MdiChildForm).Add()
End If
End Sub
How could I change mode of active mdi child form ?
Remember there are several forms.
Thank you.
Get it.
One more problem.
Private Sub btnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim frm As Form = Me.ActiveMdiChild
If Not IsNothing(frm) AndAlso TypeOf frm Is MdiChildForm Then
DirectCast(frm, MdiChildForm).Add()
End If
End Sub
How could I change mode of active mdi child form ?
Remember there are several forms.
Thank you.
ASKER
I use :
Public Interface MdiChildForm
Sub Add()
Sub Update()
Sub Delete()
Sub Save()
Sub Print()
Sub Cancel()
End Interface
at mdi form.
Thank you.
Public Interface MdiChildForm
Sub Add()
Sub Update()
Sub Delete()
Sub Save()
Sub Print()
Sub Cancel()
End Interface
at mdi form.
Thank you.
You'd have to add Mode() to your Interface!
ASKER
- You'd have to add Mode() to your Interface!
I don't get it.
Private Sub btnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Me.intMode = ERV_GLOBAL.MB_ADD
Dim frm As Form = Me.ActiveMdiChild
If Not IsNothing(frm) AndAlso TypeOf frm Is MdiChildForm Then
DirectCast(frm, MdiChildForm).Add()
mdichild.mode = me.intMode --> How to do this ?
End If
End Sub
How could I do it ?
Thank you.
I don't get it.
Private Sub btnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Me.intMode = ERV_GLOBAL.MB_ADD
Dim frm As Form = Me.ActiveMdiChild
If Not IsNothing(frm) AndAlso TypeOf frm Is MdiChildForm Then
DirectCast(frm, MdiChildForm).Add()
mdichild.mode = me.intMode --> How to do this ?
End If
End Sub
How could I do it ?
Thank you.
ASKER
Sorry,
Private Sub btnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Me.intMode = ERV_GLOBAL.MB_ADD
Dim frm As Form = Me.ActiveMdiChild
If Not IsNothing(frm) AndAlso TypeOf frm Is MdiChildForm Then
DirectCast(frm, MdiChildForm).Add()
--problem below code
Me.ShowHideControl(intMode , frm.clsFormAuthority)
End If
End Sub
Thank you.
Private Sub btnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Me.intMode = ERV_GLOBAL.MB_ADD
Dim frm As Form = Me.ActiveMdiChild
If Not IsNothing(frm) AndAlso TypeOf frm Is MdiChildForm Then
DirectCast(frm, MdiChildForm).Add()
--problem below code
Me.ShowHideControl(intMode
End If
End Sub
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry Mode has no problem anymore since I have code at form3 below :
Public Class Form3
Implements MdiChildForm
Public clsFormAuthority As clsFormAuthority
Private intMode As Int16 = ERV_GLOBAL.MB_VIEW
Public Sub New(ByVal clsFormAuthority As clsFormAuthority)
Me.InitializeComponent()
Me.clsFormAuthority = clsFormAuthority
End Sub
Public Property Mode() As Integer
Get
Return intMode
End Get
Set(ByVal value As Integer)
intMode = value
End Set
End Property
Public Sub Add() Implements MdiChildForm.Add
Me.Mode = ERV_GLOBAL.MB_ADD
MsgBox(Me.Name & " CREATE")
End Sub
End Sub
The problem is to access clsFormAuthority at mdi parent.
Private Sub btnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Me.intMode = ERV_GLOBAL.MB_ADD
Dim frm As Form = Me.ActiveMdiChild
If Not IsNothing(frm) AndAlso TypeOf frm Is MdiChildForm Then
DirectCast(frm, MdiChildForm).Add()
'Me.ShowHideControl(intMod e, frm.clsFormAuthority)
End If
End Sub
frm.clsFormAuthority is the problem now.
Thank you.
Public Class Form3
Implements MdiChildForm
Public clsFormAuthority As clsFormAuthority
Private intMode As Int16 = ERV_GLOBAL.MB_VIEW
Public Sub New(ByVal clsFormAuthority As clsFormAuthority)
Me.InitializeComponent()
Me.clsFormAuthority = clsFormAuthority
End Sub
Public Property Mode() As Integer
Get
Return intMode
End Get
Set(ByVal value As Integer)
intMode = value
End Set
End Property
Public Sub Add() Implements MdiChildForm.Add
Me.Mode = ERV_GLOBAL.MB_ADD
MsgBox(Me.Name & " CREATE")
End Sub
End Sub
The problem is to access clsFormAuthority at mdi parent.
Private Sub btnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Me.intMode = ERV_GLOBAL.MB_ADD
Dim frm As Form = Me.ActiveMdiChild
If Not IsNothing(frm) AndAlso TypeOf frm Is MdiChildForm Then
DirectCast(frm, MdiChildForm).Add()
'Me.ShowHideControl(intMod
End If
End Sub
frm.clsFormAuthority is the problem now.
Thank you.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok. Let me try it.
Thank you.
Thank you.
ASKER
-(1) Cast "frm" to a Type that does have knowledge of "clsFormAuthority".
Have no idea about it.
- (2) Add "clsFormAuthority" as a Property of MdiChildForm Intefrace (just like Mode).
Let me try first.
Thank you.
Have no idea about it.
- (2) Add "clsFormAuthority" as a Property of MdiChildForm Intefrace (just like Mode).
Let me try first.
Thank you.
ASKER
Public Interface MdiChildForm
Sub Add()
Sub Update()
Sub Delete()
Sub Save()
Sub Print()
Sub Cancel()
Sub FormAuthority()
End Interface
Public Property FormAuthority() Implements MdiChildForm.FormAuthority
Get
Return clsFormAuthority
End Get
Set(ByVal value As Object)
clsFormAuthority = value
End Set
End Property
Error 1 Class 'Form3' must implement 'Sub FormAuthority()' for interface 'MdiChildForm'.
Error 2 'FormAuthority' cannot implement 'FormAuthority' because there is no matching property on interface 'MdiChildForm'.
Thank you.
Sub Add()
Sub Update()
Sub Delete()
Sub Save()
Sub Print()
Sub Cancel()
Sub FormAuthority()
End Interface
Public Property FormAuthority() Implements MdiChildForm.FormAuthority
Get
Return clsFormAuthority
End Get
Set(ByVal value As Object)
clsFormAuthority = value
End Set
End Property
Error 1 Class 'Form3' must implement 'Sub FormAuthority()' for interface 'MdiChildForm'.
Error 2 'FormAuthority' cannot implement 'FormAuthority' because there is no matching property on interface 'MdiChildForm'.
Thank you.
Follow the same process as we did for "Mode" back here:
https://www.experts-exchange.com/questions/27980871/ACCESS-MDICHILD-VARIABLES-OR-PROPERTIES.html?anchorAnswerId=38731796#a38731796
https://www.experts-exchange.com/questions/27980871/ACCESS-MDICHILD-VARIABLES-OR-PROPERTIES.html?anchorAnswerId=38731796#a38731796
ASKER
Public Interface MdiChildForm
Sub Add()
Sub Update()
Sub Delete()
Sub Save()
Sub Print()
Sub Cancel()
Property FormAuthority()
End Interface
Public Property FormAuthority() As Object Implements MdiChildForm.FormAuthority
Get
Return clsFormAuthority
End Get
Set(ByVal value As Object)
clsFormAuthority = value
End Set
End Property
Then what should I do at main form ?
Thank you.
Sub Add()
Sub Update()
Sub Delete()
Sub Save()
Sub Print()
Sub Cancel()
Property FormAuthority()
End Interface
Public Property FormAuthority() As Object Implements MdiChildForm.FormAuthority
Get
Return clsFormAuthority
End Get
Set(ByVal value As Object)
clsFormAuthority = value
End Set
End Property
Then what should I do at main form ?
Thank you.
ASKER
I try this.
Private Sub btnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Me.intMode = ERV_GLOBAL.MB_ADD
Dim frm As Form = Me.ActiveMdiChild
If Not IsNothing(frm) AndAlso TypeOf frm Is MdiChildForm Then
DirectCast(frm, MdiChildForm).Add()
clsFormAuthority = DirectCast(frm, MdiChildForm).FormAuthorit y
Me.ShowHideControl(intMode , clsFormAuthority)
End If
End Sub
Thank you.
Private Sub btnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Me.intMode = ERV_GLOBAL.MB_ADD
Dim frm As Form = Me.ActiveMdiChild
If Not IsNothing(frm) AndAlso TypeOf frm Is MdiChildForm Then
DirectCast(frm, MdiChildForm).Add()
clsFormAuthority = DirectCast(frm, MdiChildForm).FormAuthorit
Me.ShowHideControl(intMode
End If
End Sub
Thank you.
...and does that work now?
Instead of using DirectCast() each time, you can create a local variable to use:
Instead of using DirectCast() each time, you can create a local variable to use:
Private Sub btnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Me.intMode = ERV_GLOBAL.MB_ADD
Dim frm As Form = Me.ActiveMdiChild
If Not IsNothing(frm) AndAlso TypeOf frm Is MdiChildForm Then
Dim child As MdiChildForm = DirectCast(frm, MdiChildForm)
' ... now use "child" ...
child.Add()
Me.ShowHideControl(intMode, child.FormAuthority)
End If
End Sub
ASKER
Hi All,
Thank to all of you very much for your help.
Thanks to Idle Mind that helps a lot.
Thank to all of you very much for your help.
Thanks to Idle Mind that helps a lot.
and the cast your reference to form like ActiveChild in Form3 and then you can access the required data member directly.