首页 > 解决方案 > how to add a row in a datagridview via other form using C#

问题描述

I'm stuck in a problem in windown form (C#). I have MainUI form consist of a DataGridView, that contains data in my database and a button called BtnRegister. And I have Register form containing some TextBoxs, CheckBoxs... and a confirm button. When I click BtnRegister, Register form is shown and I can input data by typing in textboxs, ... and confirm data inputed by clicking confirm button. The problem is that I dont known how to add a new row into DataGridView in MainUI form by clicking confirm button in Register form. enter image description here

Sorry, my English is not good. But I have a significant hope that some one can help to solve this problem. Thank you.

标签: c#datagridview

解决方案


只需观察主窗体中的对话框结果即可。例如:

If (register.ShowDialog() == DialogResult.OK)
{
    dataGridView.Add();
    // do something
}

推荐阅读