Exemplo n.º 1
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            //if (e.ColumnIndex == 0 && e.RowIndex != -1)
            //{
            //    //var confirmResult = MessageBox.Show("Bạn có muốn xóa ??",
            //    //                     "Cảnh báo!!",
            //    //                     MessageBoxButtons.YesNo);
            //    //if (confirmResult == DialogResult.Yes)
            //    //{
            //    //    //int id = Int32.Parse(dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString());

            //    //}

            //}
            //else if (e.RowIndex != -1)
            //{
            txtMa.Text  = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
            txtTen.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
            if (!String.IsNullOrEmpty(dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString()))
            {
                dateTimePicker1.Value = DateTime.Parse(dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString());
            }
            txtSdt.Text             = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();
            cbGioiTinh.SelectedItem = Ham.TrueFalseToNamNu(Boolean.Parse(dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString()));
            txtQueQuan.Text         = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString();
            txtUsername.Text        = dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString();
            //txtUsername.Text = dataGridView1.Rows[e.RowIndex].Cells[9].Value.ToString();

            checkActive.Checked = dataGridView1.Rows[e.RowIndex].Cells[7].Value.ToString() == "True" ? true : false;
            Console.WriteLine(checkActive.Checked);
            cbQuyen.SelectedItem = dataGridView1.Rows[e.RowIndex].Cells[8].Value.ToString();
            //}
        }