Alright, this probably already has a thread somewhere( which if someone knows of, feel free to point me in that direction!), but a while of searching hasn't led me to it.
I'm currently using the datagrid viewer to display a table in my vb.net (VS 2013) program. I'm not using a database/sql setup (although there is a good number of tutorials online on that one). I look on my network for whatever devices I have connected. I'm going to get their IP address, firmware, time accessed, etc into a string.
like so:
Dim device_info as string() = {"webcam", "123.123.123.123", _
"3/18/2014", "firmware version 2"}
You get the idea.
So I'll have an array of strings about this device, and multiple devices in a row. Basically a table of each device and the corresponding info.
My issue is that I'm trying to display this info in data grid, and I can't quite it it right. I want each row to be a device, and each element of the device_info array of strings to be a cell. And possibly a column of checkboxes to select(a problem I can deal with later). But I'm having issues making a matrix or an array of arrays, and being able to display that into the gridviewer. Here's what I have so far (with junk strings inputted for the exercise):
Dim device1 As String() = {"Acti", "00:09:10", "SF0900", "FirmwareVersion 1.0"}
Dim device2 As String() = {"Sony", "03:45:h5", "KK5000", "Firm ware 8.0"}
Dim arraylist As New ArrayList
arraylist.Add(device1)
arraylist.Add(device2)
Dim dt As New DataTable
dt.Columns.Add("Brand")
dt.Columns.Add("Mac")
dt.Columns.Add("Model")
dt.Columns.Add("Firmware")
For i As Integer = 0 To arraylist.Count - 1
Dim dr As DataRow
dr = dt.NewRow()
For j As Integer = 0 To dt.Columns.Count - 1
dr.Item(j) = arraylist(j)
Next
dt.Rows.Add(dr)
Next
dataGridViewer.DataSource = dt
This errors out in the build, mostly because of the arraylist(j) line. I really want to access arraylist(device(j)), but I'm unclear on how to do that. Is there a way to access an element of an array that is within an array list? Or am I going about this the whole wrong way and there is a more efficient method? I basically want to copy a matrix and import it into the grid viewer. Feeling like bit of a dummy here :D.
Thanks for the help!! -K