Advertisement
Guest User

Select All

a guest
Jul 11th, 2019
1,464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.79 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace SelectAlll
  12. {
  13. public partial class SelectAll: UserControl
  14. {
  15. public SelectAll()
  16. {
  17. InitializeComponent();
  18. }
  19.  
  20. public List<string> Estados = new List<string>();
  21. private void SelectAll_Load(object sender, EventArgs e)
  22. {
  23.  
  24. }
  25.  
  26. public void Deschequear()
  27. {
  28. chk.Checked = false;
  29. }
  30.  
  31. private void chk_CheckedChanged(object sender, EventArgs e)
  32. {
  33. foreach (Control r in this.ParentForm.Controls)
  34. {
  35. if (r is CheckBox)
  36. {
  37.  
  38. if(((CheckBox)r).Checked == false )
  39. {
  40. Graphics g = this.ParentForm.CreateGraphics();
  41.  
  42. int x = r.Location.X;
  43. int y = r.Location.Y;
  44. int ancho = r.Size.Height;
  45. int largo = r.Size.Width;
  46.  
  47. g.DrawRectangle(Pens.Blue, x - 2, y - 2, largo + 2, ancho + 2);
  48.  
  49. }
  50.  
  51.  
  52.  
  53.  
  54. if (chk.Checked == true)
  55. {
  56. Estados.Add(((CheckBox)r).Name.ToString() + ','+((CheckBox)r).Checked.ToString());
  57. ((CheckBox)r).Checked = true;
  58. }
  59.  
  60. if (chk.Checked == false)
  61. {
  62. foreach (string s in Estados)
  63. {
  64. string[] chkestados = s.Split(',');
  65. if ( ((CheckBox)r).Name == chkestados[0])
  66. {
  67. ((CheckBox)r).Checked = bool.Parse(chkestados[1]);
  68.  
  69. if (((CheckBox)r).Checked == false)
  70. {
  71.  
  72. Graphics g = this.ParentForm.CreateGraphics();
  73. Pen p = new Pen(this.ParentForm.BackColor);
  74. int x = r.Location.X;
  75. int y = r.Location.Y;
  76. int ancho = r.Size.Height;
  77. int largo = r.Size.Width;
  78.  
  79. g.DrawRectangle(p, x - 2, y - 2, largo + 2, ancho + 2);
  80.  
  81. }
  82.  
  83. }
  84. }
  85. }
  86.  
  87. }
  88. }
  89. }
  90. }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement