vb.netwinformsdatarepeaterpowerpacks

Iterate thru DataRepeater (VB.Net PowerPack)


I am using the winform datarepeater control from vb.net power pack.

All of the items on the repeater are readonly except for a checkbox column.

I want to iterate over the items and find out which checkboxes are checked.

I can't find a collection of datarepeateritems on the control and help is scarce.

Thanks for the help.


Solution

  • You could iterate through the Controls list (generated from template)

    1. Rename your checkbox in the datarepeater to "checkBoxUnbound"

    2. Use the below code

      private void button3_Click(object sender, EventArgs e)
      {
          int i = 0;
          CheckBox unboundCheckBox;
          foreach (Control c in dataRepeater1.Controls)
          {
              unboundCheckBox = c.Controls["checkBoxUnbound"] as CheckBox;
              if (unboundCheckBox != null && unboundCheckBox.Checked)
              {
                  i++;
              }
          }
      
          Console.WriteLine("DEBUG: checked found: " + i);
      
      }