Answer the question
In order to leave comments, you need to log in
How to display number in hexadecimal format in DataGridView?
Good afternoon, I'm just starting to write in C #, I wrote an application that communicates with STM32 via USB-CDC, in fact CAN - Sniffer, reads a line, converts it to hex, sorts it by Id and saves it to a class (I immediately wanted to save it to a structure, but not came out due to access and initialization of the fields of the structure in the stream, they were reset to zero)
class CAN_RX_Class
{ static public uint[] Id = new uint[max_message];
static public byte[] DLC = new byte[max_message];
static public byte[] Byte0 = new byte[max_message];
static public byte[] Byte1 = new byte[max_message];
static public byte[] Byte2 = new byte[max_message];
static public byte[] Byte3 = new byte[max_message];
static public byte[] Byte4 = new byte[max_message];
static public byte[] Byte5 = new byte[max_message];
static public byte[] Byte6 = new byte[max_message];
static public byte[] Byte7 = new byte[max_message];
static public ushort[] CAN_count = new ushort[max_message];
static public ushort number_last_string;
static public ushort current_line_number = 0;
}
uint ID_array = 0;
for (byte j = 5, offset = 28; j <= 12; j++, offset -= 4)
ID_array += (uint)((_bufer[j].MyAsciiToHex()) << offset);
if (CAN_RX_Class.number_last_string == 0)
{
//формируем ID
CAN_RX_Class.Id[i] = ID_array;
//Формируем DLC
CAN_RX_Class.DLC[i] = _bufer[13].MyAsciiToHex();
//Формируем BYTS
CAN_RX_Class.Byte0[0] = (byte)(((_bufer[14].MyAsciiToHex()) << 4) + (_bufer[15].MyAsciiToHex()));
//добавляем пустые строки >>
for (; CAN_RX_Class.current_line_number <= CAN_RX_Class.number_last_string; ++CAN_RX_Class.current_line_number)
Invoke(new Action(() =>
{
dataGrid_CAN1.Rows[dataGrid_CAN1.Rows.Add()].Cells[0].Value = CAN_RX_Class.current_line_number + 1;
}));
//<<
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question