Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace WindowsFormsApp1
  12. {
  13.  
  14.   public partial class Form1 : Form
  15.   {
  16.     public Form1()
  17.     {
  18.       InitializeComponent();
  19.     }
  20.  
  21.     class Platform
  22.     {
  23.       public string ControlName { get; set; }
  24.  
  25.       public int Order { get; set; }
  26.       public bool Checked { get; set; }
  27.     }
  28.  
  29.     private void Form1_Load(object sender, EventArgs e)
  30.     {
  31.  
  32.       List<Platform> platforms = new List<Platform>
  33.       {
  34.         new Platform
  35.         {
  36.           ControlName = this.checkBox1.Name,
  37.           Order = 1
  38.         }
  39.       };
  40.  
  41.       bool[] platformsArray = platforms.OrderBy(p => p.Order).Select(p => p.Checked).ToArray();
  42.  
  43.       var controls = this.Controls.OfType<CheckBox>().ToArray();
  44.       foreach (var item in controls)
  45.       {
  46.         var platform = platforms.First(p => p.ControlName == item.Name);
  47.         platform.Checked = item.Checked;
  48.       }
  49.     }
  50.   }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement