When I start a form without sending information, it opens the list view correctly with the column headers.
However, when I try to open the same form to update information, the listview loses the headers. non-existent fcam and all the rest of the programming on top of the listview
normal opening without sending data
Code:
public FrmMicroConfig() { InitializeComponent(); }
opening with data sending
`public FrmMicroConfig(string device) : this()
{
Dispostivo dispositivo = Dispostivo.JsonDesserializar(device);
txtDevicename.Text = dispositivo.Nome;
txtDeviceIp.Text = dispositivo.IP;
txtDeviceLocal.Text = dispositivo.Local;
LstdeviceVariables.Columns.Add("Nome");
LstdeviceVariables.Columns.Add("Id");
LstdeviceVariables.Columns.Add("StartBit");
LstdeviceVariables.Columns.Add("Lenght");
LstdeviceVariables.Columns.Add("Factor");
LstdeviceVariables.Columns.Add("Offset");
foreach (var Variable in dispositivo.Variables)
{
ListViewItem lvi = new ListViewItem(Variable.Nome);
lvi.SubItems.Add(Variable.Id.ToString());
lvi.SubItems.Add(Variable.Startbit.ToString());
lvi.SubItems.Add(Variable.Lenght.ToString());
lvi.SubItems.Add(Variable.Factor.ToString());
lvi.SubItems.Add(Variable.Offset.ToString());
LstdeviceVariables.Items.Add(lvi);
}
InitializeComponent();
}`
The result of this are these two screens
Normal open:
enter image description here
Wrong Open:
enter image description here
I can’t identify where the error comes from
I already tried adding the headers later and nothing
and even without adding items to the listview the result is the same
the listview does not work correctly
Any idea how this error is generated? Maybe some wrong class configuration or object type?