foxxs Posted November 18, 2012 Report Share Posted November 18, 2012 I've created a fairly workable application to retrieve data from the data tables of the PLC's (PL-570) i'm working with, however I would like to also be able to gather all of the operands (MB, MI, SI, etc) as well, and format them into organized datagridviews in vb.net. I'd like to use a similar method as I've used for the tables if possible: Public Sub ReadDataTables(IP As String, port As Integer, protocal As EthProtocol, retries As Integer, timeoutMs As Integer) Dim frmClockTables As New Form Dim Tabs As New TabControl frmClockTables.Controls.Add(Tabs) Tabs.Dock = DockStyle.Fill Try ethernet1 = New Ethernet(IP, port, protocal, retries, timeoutMs) plc1 = PLCFactory.GetPLC(ethernet1, 0) dtTables = New DataTables(plc1, DataTablesReadOptions.StructureAndValues) Catch ex As Exception MessageBox.Show("Could not connect to " & IP & " on port " & port) End Try Try ethernet1 = New Ethernet(IP, port, protocal, retries, timeoutMs) plc1 = PLCFactory.GetPLC(ethernet1, 0) dtTables = New DataTables(plc1, DataTablesReadOptions.StructureAndValues) Catch ex As Exception MessageBox.Show("Could not connect to " & IP & " on port " & port) End Try Dim colcount As Integer = 0 Dim rowcount As Integer = 0 For Each item In dtTables.Tables Dim data As New DataGridView Dim tab As New TabPage tab.Text = item.Name.ToString tab.Controls.Add(data) data.Dock = DockStyle.Fill Tabs.TabPages.Add(tab) colcount = item.Columns.Count rowcount = item.Rows.Count Dim i As Integer = 0 For Each column In item.Columns data.ColumnCount = colcount data.RowCount = rowcount data.Columns(i).Name = column.Name.ToString For Each Cell In column.Cells Dim cellvalue As String = "" For Each Field In Cell.Fields If Not cellvalue = "" Then cellvalue &= ";" End If cellvalue &= Field.Value Next data.Rows(Cell.RowIndex).Cells(Cell.ColumnIndex).Value = cellvalue Next i += 1 Next NumberAllRows(data) Next frmClockTables.Show() End Sub how can this be done, or can it be done at all? Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.