Bien, avec ces nouvelles spécifications :
Soit :
1 2 3 4 5 6 7
| For Each tp As TabPage In TabControl1.TabPages
For Each pan In tp.Controls.OfType(Of Panel)()
For Each ckb As CheckBox In pan.Controls.OfType(Of CheckBox)() ' ici traitement de tous les checkbox
wsExcel.Range(ckb.Tag).Value = ckb.Checked
Next
Next
Next |
Soit
Array.ForEach(GetAllControls(Of CheckBox)(Me).ToArray, Sub(ckb) wsExcel.Range(ckb.Tag).Value = ckb.Checked)
en utilisant la méthode
1 2 3 4
| Function GetAllControls(Of TControl As Control)(source As Control) As IEnumerable(Of TControl)
Dim children = source.Controls.Cast(Of Control)()
Return children.SelectMany(Function(child) GetAllControls(Of TControl)(child)).OfType(Of TControl).Concat(children.OfType(Of TControl))
End Function |
Résultat (tabpage2 = colonne B) :
Partager