Hi,
I have created a ModbusPollFormFull() form with DataGridView in it. The DataGridView will continuously update the data every second. I put a "NEW FORM" menu item/button in order to create the exact form. I want whenever i created those new forms,they have the ability to update the data in DGV as well but having its own control.
My problem is, those new forms did not showed me any data at all during the runtime. How can i solves this problem?
Thank you
Private Sub NewMenuItem_File_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click
Start += 1
For i As Integer = 0 To Start
NewForm = New ModbusPollFormFull()
NewForm.Text = "ModbusPoll:" & i
Next
i already have a different class for reading the hardware, which is "Modbus" class to help me populate the data.
I use the MainForm() to call the Modbus()class functions (using PollFunction() method and timer elapsed as well) and i create another form,ModBusPollFormFull()to read the data through DataGridView1 ("Address","ID","Value" columns).
I have two forms (MainForm and ModbusPollFormFull()).
ModbusPollFormFull() consists of DataGridView1, and and two label (poll count label and NoConnection label).
There is a three button on MainForm. ("New Form" )button to create multiple instance of ModbusPollFormFull().
("Start") button to start populate DataGridView1 data in ModbusPollFormFull() and ("Stop") button to stop populate DataGridView1 data in ModbusPollFormFull().
The DataGridView1 is populate during runtime(timer-elapsed) and obviously the values in DataGridView1 are changing every second.
Poll Count label shows the counter when the ("Start") button is clicked. NoConnection label will be visible when the ("Stop") button is clicked.
When i clicked ("New Form") button, i want the new ModbusPollFormFull() will be able to start the Poll Count from zero
and the DataGridView1 in the new ModbusPollFormFull() will be able to populate data as in the existing ModbusPollFormFull().
Private Sub NewForm_File_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewForm.Click
Dim nf As Form
For i As Integer = 0 To Start
nf = New ModbusPollFormFull()
nf.Text = "ModbusPollForm:" & i
nf.Name = "ModbusPollFormFull" & i
For j As Integer = 20 To Inc
nf.Left = j
Next
Next
nf.Show()
Private Sub PollFunction()
DoGUIClear()
pollCount += 1
ModbusPollformFull.mpfDoGUIStatus("Poll count:" & pollCount.ToString())
Dim values(CInt(QuantityCB.Text)) As Short
Dim pollStart As UShort
Dim pollLength As UShort
If AddressCB.Text <> "" Then
pollStart = Convert.ToUInt16(AddressCB.Text)
Else
pollStart = 0
End If
If QuantityCB.Text <> "" Then
pollLength = Convert.ToUInt16(QuantityCB.Text)
Else
pollLength = 20
End If
Try
Modbus.ReadHoldingRegister_Fc3((Convert.ToByte(SlaveIDCB.Text)), pollStart, pollLength, values)
Catch ex As Exception
DoGUIStatus("Error in modbus read : " & ex.Message)
End Try
Dim itemString As String
Dim itemString2 As String
Dim itemString3 As String
Select Case dataType
Case "Hexadecimal"
For i As Integer = 0 To pollLength - 1
itemString = Convert.ToString(pollStart + i)
itemString2 = Convert.ToString(pollStart + i + 1)
itemString3 = values(i).ToString("X")
DoGUIUpdate(itemString, itemString2, itemString3)
Next i
Case "Decimal"
For i As Integer = 0 To pollLength - 1
itemString = Convert.ToString(pollStart + i)
itemString2 = Convert.ToString(pollStart + i + 1)
itemString3 = values(i).ToString("")
DoGUIUpdate(itemString, itemString2, itemString3)
Next i
End Select
End Sub
Can you help me?