using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace UAS_MES.CustomControl.ButtonUtil { public partial class ChooseAllButton : Button { DataGridView DGV; bool AllChecked = false; public ChooseAllButton() { InitializeComponent(); } public void ChooseAll(DataGridView dgv) { DGV = dgv; Click += ChooseAll_Click; } private void ChooseAll_Click(object sender, EventArgs e) { if (AllChecked) { for (int i = 0; i < DGV.RowCount; i++) { DGV.Rows[i].Cells[0].Value = false; } AllChecked = false; } else { for (int i = 0; i < DGV.RowCount; i++) { DGV.Rows[i].Cells[0].Value = true; } AllChecked = true; } } } }