Hello All,
I'm able to read specific data from a XML file. But the way the file is set up and how I would like my program works I need to create (I think) something like a datatable or so. Unfortunately i'm not sure how to tackle this issue.
The XML file looks like this:
<Root>
<CompanyProfile>
<CompanyName>Raymond</CompanyName>
<SiteName>Gilbers</SiteName>
<Imo>123654</Imo>
<MachineTotal>2</MachineTotal>
</CompanyProfile>
<MachineProfile>
<MachineName>mach1</MachineName>
<SerialNumber>123987</SerialNumber>
<TypeNumber>AMI500</TypeNumber>
<Type>AC</Type>
<NominalSpeed>3000</NominalSpeed>
<Frequency>50</Frequency>
<NominalPower>1500</NominalPower>
</MachineProfile>
<MachineProfile>
<MachineName>Mach2</MachineName>
<SerialNumber>987654</SerialNumber>
<TypeNumber>AMZ500</TypeNumber>
<Type>AC</Type>
<NominalSpeed>1500</NominalSpeed>
<Frequency>50</Frequency>
<NominalPower>1700</NominalPower>
</MachineProfile>
</Root>
what I want is to read the machineprofile. And "connect" the machinename to a combobox. So in other words I want the combobox has the items mach 1, mach2 mach3 etc and when I selet a particular selection all specific items whith this machine will be displayed.
I'm able to read the XML that is not the issue I guess but I don't know how to tackle the next issue....do I need to make a new method or create a DataTable or so. I know how machine "Machines exsist" so I thought I create a kind of loop and place it in a method but that will not work I really think I have to place each data in a table. And the selection should have some kind of identity (e.g a number) which shows me later on all the info I want to see.
How can I do this?
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
using (OpenFileDialog ofd = new OpenFileDialog())
{
ofd.Filter = "XML File (*.xml)|*.xml";
ofd.Title = "Open Client Profile File";
if (ofd.ShowDialog() == DialogResult.OK)
{
//Deserialize
_root = HelperXml.DeserializeXMLFileToObject<XmlRoot>(ofd.FileName);
lblCompanyName.Text = _root.CompanyProfile.CompanyName;
lblSiteName.Text = _root.CompanyProfile.SiteName;
lblImo.Text = _root.CompanyProfile.Imo.ToString();
lblMachineTotal.Text = _root.CompanyProfile.MachineTotal.ToString();
lblClientNumber.Text = _root.CompanyProfile.ClientNumber.ToString();
//Parse machine total to a machine total number.
int counter = Int32.Parse(lblMachineTotal.Text);
}
}
}
All the previous lables I'm able to read correctly but as you can see the Mach1 till 3 I would like to make vissible with selecting a selection in a combobox:
This combobox e.g. the top left one should show mach 1, mach 2 etc en selecting a particular one it should show all its relevant info. What should I do?
Maybe someone could give me some ideas.
Thanks in advance!