private void dgvDevice_CellClick(object sender, DataGridViewCellEventArgs e) { // Cai dat cau hinh if (e.ColumnIndex == 5) { int index = e.RowIndex; SettingDevice settingDevice = new SettingDevice(); settingDevice.DeviceName = dgvDevice.Rows[index].Cells[1].Value.ToString(); settingDevice.Cops = dgvDevice.Rows[index].Cells[2].Value.ToString(); settingDevice.DelayTime = Int32.Parse(dgvDevice.Rows[index].Cells[3].Value.ToString()); settingDevice.Limit = Int32.Parse(dgvDevice.Rows[index].Cells[4].Value.ToString()); SetupDeviceForm deviceSetupForm = new SetupDeviceForm(); deviceSetupForm.dataSetup = settingDevice; deviceSetupForm.ShowDialog(); dgvDevice.Rows[index].Cells[2].Value = deviceSetupForm.cbMangDiDong.SelectedValue.ToString(); dgvDevice.Rows[index].Cells[3].Value = deviceSetupForm.cbDoTre.SelectedValue.ToString(); dgvDevice.Rows[index].Cells[4].Value = deviceSetupForm.cbGioiHan.SelectedValue.ToString(); dgvDevice.Refresh(); // Create a new file in C:\\ dir WriteXML(envPath + "\\" + dgvDevice.Rows[e.RowIndex].Cells[2].Value + ".xml", new SettingDevice(dgvDevice.Rows[e.RowIndex].Cells[1].Value.ToString(), dgvDevice.Rows[e.RowIndex].Cells[2].Value.ToString(), Int32.Parse(dgvDevice.Rows[e.RowIndex].Cells[3].Value.ToString()), Int32.Parse(dgvDevice.Rows[e.RowIndex].Cells[4].Value.ToString()))); } }