1

Case: I'm trying to create a few checkboxes which define what radiobutton is set by default. I don't have a clue how to approach this, to create the radiobuttons I'm using this xml:

<Lijsten>
<Lijst>
    <Titel>Discipline</Titel>
    <Waardes>Elektro</Waardes>
    <Waardes>Mechanisch</Waardes>
    <Waardes>Civiel</Waardes>
    <Waardes>Proces</Waardes>
    <Waardes>N.v.t.</Waardes>
</Lijst>
<Lijst>
<Titel>Discipline</Titel>
    <Waardes>Elektro</Waardes>
    <Waardes>Mechanisch</Waardes>
    <Waardes>Civiel</Waardes>
    <Waardes>Proces</Waardes>
    <Waardes>N.v.t.</Waardes>
</Lijst>
<Lijst>
<Titel>Discipline</Titel>
    <Waardes>Elektro</Waardes>
    <Waardes>Mechanisch</Waardes>
    <Waardes>Civiel</Waardes>
    <Waardes>Proces</Waardes>
    <Waardes>N.v.t.</Waardes>
</Lijst>
</Lijsten>

C# code:

foreach (XmlNode node in nodes)
{
     int heightRadioButtons = 0;
     WidthPanelsRow1 += 155;
     Panel panel = new Panel();
     panel.Size = new Size(140, 200);
     panel.Location = new Point(WidthPanelsRow1, heightPanelsRow1);
     panel.Name = "panel" + count.ToString();
     panel.BackColor = Color.LightGray;

     Label lbl = new Label();
     lbl.Text = node["Titel"].InnerText;
     lbl.Location = new Point(0, 0);
     lbl.Font = font1;
     panel.Controls.Add(lbl);

     int counterLastRadioButton = 0;
     XmlNodeList waardeNodes = node.SelectNodes("Waardes");
     foreach (XmlNode wNode in waardeNodes)
     {
             counterLastRadioButton += 1;
             heightRadioButtons += 20;
             RadioButton rb = new RadioButton();
             rb.Text = wNode.InnerText;
             rb.Location = new Point(5, heightRadioButtons);
             rb.Name = node["Titel"].InnerText;
             if (waardeNodes.Count - 1 < counterLastRadioButton)
             {
                  rb.Checked = true;
             }
             panel.Controls.Add(rb);
     }
     this.Controls.Add(panel);
}

What I'm trying to achieve: Create a checkbox dynamically from the xml, with per "Titel" the default "Waardes". So if I check that checkbox, the radiobutton of that "Titel" will change to that "value".

Jonas
  • 121,568
  • 97
  • 310
  • 388
Niels
  • 95
  • 2
  • 9
  • Are you sure that you use the term `checkbox` in the correct way? Maybe you can include a picture that shows your desired UI and describe the planned flow of user interaction. – grek40 Oct 17 '17 at 09:05
  • Yes, i want to create checkboxes which sets the different radiobuttons options to the value described in the xml file. Example: checkbox 1 : sets radiobuttion option 1 (1,2,3,4,5) to default 5 and sets radiobuttion option 2 ("test", "stack", "forum") to default "forum"). With default i obviously mean selected radiobutton. These presets can be defined in the same xml. – Niels Oct 17 '17 at 12:04

0 Answers0