Read Serial Data and display in DataGrid View

ejleiss

Active member
Joined
Oct 1, 2012
Messages
37
Programming Experience
1-3
Hello,

I am able to read data from a serial port and store it in an array, but I would like to be able to take those array values (hex values) and display them in a DataGrid. Would someone be able to direct me to some sample code that helps explain this?

Thank you.
 
What EXACTLY is in your array and what EXACTLY do you expect to see in your grid?

The array is an array of bytes and I would like to see a 6 column data grid that displays the bytes. (ie say my array consists of 0x55, 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x55, 0xFF... etc. I would like to see this in my grid:

0x55 0xFF 0x01 0x02 0x03 0x04
0x05 0x06 0x07 0x08 0x55 0xFF
... etc


Thank you
 
If you have a Byte array then it doesn't contain hex values; it contains Bytes. Unless you want to load the data into the grid manually, you'll need to first define a type that has six Byte properties. You would then create an array or collection of that type, populating each instance with six elements from the array. You could use a For loop with a Step of 6 for that. You can then bind that list to the grid. If you want the values displayed in hexadecimal format then you'd have to set the DefaultCellStyle.Format of each column.
 
Back
Top