Click here to Skip to main content
15,892,005 members

Handling form in multiple forms created -Addressing the sender form

juita asked:

Open original thread
Hi,

I am new to vb.net.I have three form.
The first one is MDIparent form (Mainform) which will created unlimited MDIchild form of (Mpfform).Mpfform contain Data Grid View.
Each Mpfform can create only one (Dmfform -non MDI).
Dmfform contain one "Start" button.

My problem is, how can i address the specific Mpfform created by Mainform or
Dmfform created from specific Mpfform?

Ive tried using my code below with no success. Please help me.

1) code in Mainform : to create Mpfform

VB
Public mpf(50) As Mpfform()
Public num As Integer = 0
 
Private Sub NewMenuItem_File_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewMenuItem_File.Click
 
        num += 1
        mpf(num) = New Mpfform()
 
'creating Mpfform

        mpf(num).Text = "ModbusPoll:" & CStr(num)
        mpf(num).Name = "ModbusPollFormFull" & num

'creating Dmfform
        mpf(num).dmf.Text = "Display Mode:" & CStr(num)
        mpf(num).dmf.Name = "Display Mode:" & num
 
'showing only Mpfform
        mpf(num).TopLevel = False
        mpf(num).BringToFront()
        mpf(num).Show()
  
 
End Sub




2) code in Mpfform - Showing Dmfform

VB
Public dmf As New Dmfform

Private Sub DataDisplayModeMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataDisplayModeMenuItem.Click
 
        dmf.Show()
        
End Sub


3)code in Dmfform - addressing problem

VB
Private Sub Start_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Start.Click
        
        If Mainform.mpf(Mainform.num).Datagridview.RowCount <> Nothing Then
        
            Me.mytimer3.Interval = 1000
            Me.mytimer3.Start()
        Else
            MsgBox("Definition of the modbus properties is currently not available." & vbNewLine & "Please define the properties in the Measurement window : Communication >> Modbus Properties")

        End If
       
End Sub


How can i address the correct DGV of Mpfform to this code?

"Mainform.mpf(Mainform.num).Datagridview.RowCount" ?
Tags: Visual Basic

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900