private void button1_Click(object sender, EventArgs e) { int i = dataGridView1.RowCount; for (int j = 0; j < i; j++) { DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)dataGridView1.Rows[j].Cells[0]; dataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit); int t = Convert.ToInt32(dataGridView1.Rows[j].Cells[3].Value); Boolean b = (bool)checkCell.Value; if (b) { dataGridView1.Rows[j].ReadOnly = true; Users u = mc.GetBruker(t); UserLogg ul = new UserLogg() { UsersId = u.Id, Brukstid = DateTime.Now }; mc.SaveUserLog(ul); } } Dispose(); }