private void dataGridView1_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { DataGridViewRow dr = dataGridView1.SelectedRows[0]; this.Hide(); frmEvent frm = new frmEvent(); // or simply use column name instead of index //dr.Cells["id"].Value.ToString(); frm.Show(); frm.txtEventID.Text = dr.Cells[0].Value.ToString(); frm.txtEventName.Text = dr.Cells[1].Value.ToString(); frm.dtpStartingDate.Text = dr.Cells[2].Value.ToString(); frm.dtpStartingTime.Text = dr.Cells[3].Value.ToString(); frm.dtpEndingDate.Text = dr.Cells[4].Value.ToString(); frm.dtpEndingTime.Text = dr.Cells[5].Value.ToString(); frm.txtManagedBy.Text = dr.Cells[6].Value.ToString(); frm.txtActivities.Text = dr.Cells[7].Value.ToString(); if (label1.Text == "Admin") { frm.btnDelete.Enabled = true; frm.btnUpdate_record.Enabled = true; frm.txtEventName.Focus(); frm.label6.Text = label1.Text; frm.btnSave.Enabled = false; } else { frm.btnDelete.Enabled = false; frm.btnUpdate_record.Enabled = false; frm.btnSave.Enabled = false; frm.txtEventName.Focus(); frm.label6.Text = label1.Text; } }
private void eventToolStripMenuItem_Click(object sender, EventArgs e) { frmEvent frm = new frmEvent(); if (UserType.Text == "Admin") { frm.label6.Text = UserType.Text; frm.Show(); } else { frm.label6.Text = UserType.Text; frm.Show(); } }