private void btn_detailTask_Click(object sender, EventArgs e) { try { FrmTaskMng frmTaskMng = new FrmTaskMng(); DataGridViewRow item = dgvProjectList.CurrentRow; if (item == null || item.Tag == null || item.Cells.Count == 0 || item.Cells[0].Value == null) { return; } frmTaskMng.ClsTask.ProjectID = Convert.ToInt32(item.Tag.ToString()); frmTaskMng.ClsTask.ProjectName = item.Cells[0].Value.ToString(); frmTaskMng.StartPosition = FormStartPosition.CenterScreen; frmTaskMng.ShowDialog(); //if (frmTaskMng.ShowDialog() == DialogResult.OK) //{ // this.DialogResult = DialogResult.OK; //} } catch (Exception) { } }
private void FrmTaskMng_Load(object sender, EventArgs e) { FrmTaskNew frmTaskNew = new FrmTaskNew(); txt_projectID.Text = ClsTask.ProjectID.ToString(); projectName = ClsTask.ProjectName; frmTaskNew.ClsTask.ProjectID = Convert.ToInt32(txt_projectID.Text); dgvTaskList.Rows.Clear(); DataTable dt; dt = ClsSQLMethod.SearchTask(); DataGridViewRow dgvRow; FrmTaskMng frmTaskMng = new FrmTaskMng(); curTask = new ClsTask(); curTask.ProjectID = frmTaskNew.ClsTask.ProjectID; foreach (DataRow row in dt.Rows) { if (row[1].ToString() == curTask.ProjectID.ToString()) { dgvRow = new DataGridViewRow(); dgvRow.CreateCells(dgvTaskList); dgvRow.Cells[0].Value = row[2].ToString(); dgvRow.Cells[1].Value = row[3].ToString(); dgvRow.Cells[2].Value = row[4].ToString(); dgvRow.Cells[3].Value = row[5].ToString(); dgvRow.Tag = row[0]; dgvTaskList.Rows.Add(dgvRow); } } //DataGridViewRow item = dgvTaskList.CurrentRow; //taskName = item.Cells[3].Value.ToString(); if (dgvTaskList.CurrentRow != null) { dgvTaskList.CurrentRow.Selected = true; } }