【发布时间】:2014-03-13 08:38:59
【问题描述】:
frmCustomerDetails cd;
private void dataGridView1_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
try
{
DataGridViewRow dr = dataGridView1.SelectedRows[0];
this.Hide();
if (cd == null || cd.IsDisposed)
{
cd = new frmCustomerDetails();
cd.MdiParent = new frmDairyManagementSystem();
cd.WindowState = FormWindowState.Maximized;
cd.Show();
}
else
cd.Activate();
cd.txtCustomerID.Text = dr.Cells[0].Value.ToString();
cd.dateTimePicker1.Text=dr.Cells[1].Value.ToString();
cd.txtCustomerName.Text = dr.Cells[2].Value.ToString();
cd.grpGender.Text=dr.Cells[3].Value.ToString();
cd.txtAddress.Text = dr.Cells[4].Value.ToString();
cd.txtPhone.Text = dr.Cells[5].Value.ToString();
cd.txtEmail.Text = dr.Cells[6].Value.ToString();
cd.txtMobileNo.Text = dr.Cells[7].Value.ToString();
cd.txtNotes.Text = dr.Cells[8].Value.ToString();
cd.btnUpdate.Enabled = true;
cd.btnDelete.Enabled = true;
cd.btnSave.Enabled = false;
cd.txtCustomerName.Focus();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
在我的主窗体中,我使用 Mdi 打开了一个子窗体。
子窗体的名称是 CustomerDetails。在该表单中,如果我想更新或删除已经存在的客户,我在 CustomerName 前面添加了一个按钮。单击该按钮后,将打开一个名为 CustomerRecord 的新表单。在这种形式中,我使用了 DataGridView,并且我编写了代码来从数据库中检索数据。
现在我希望如果单击 dataGridView1_RowHeaderMouseClick,我想在 CustomerDetails 表单上获取选定的行。
数据不在我的主窗体 frmDairyManagementSystem 上。
还有一个问题是,在 dateTimePicker 以下,grpGender 也无法正常工作。
这是我正在做的第一个项目,我必须将它提交给大学。
它没有进入我的主要形式。
请尽快帮助我
【问题讨论】:
-
它有什么“不工作”?
-
如果您提供有关哪些不工作的详细信息而不是仅仅说它“不工作”会更有用。例如,您是否遇到任何错误或异常,您是否尝试过使用断点单步执行代码?
-
如果您不知道答案,请不要发表任何评论
标签: c# sql-server winforms datagridview