I have a parent form that have a text box and button to search.
When user click on button a dialog form is opened and dialog form has a datagridview that show a data from database ( title and code). User can select one row in datagridview. when User click on one row this form is closed and the information of row (title) from dialog form show on parent form (textbox). how can send information from dialog form to parent form?
-
private void btnsearch_Click(object sender, EventArgs e)
-
{
-
Form1 showPopUp = new Form1();
-
showPopUp.ShowDialog();
-
}
-
private void Form1_Load(object sender, EventArgs e)
-
{
-
string constring = “Data Source=FV-NARMAFZAR-72;….;Initial Catalog=acc;”;
-
using (SqlConnection connection = new SqlConnection(constring))
-
{
-
Open connection
-
connection.Open();
-
using (SqlCommand command = new SqlCommand(“uspSelViewRqType”, connection))
-
{
-
command.CommandType = CommandType.StoredProcedure;
-
try
-
{
-
Execute the command
-
//command.ExecuteNonQuery();
-
SqlDataReader rdr = command.ExecuteReader();
-
DataTable dtShow = new DataTable();
-
DataRow drShow = null;
-
dtShow.Columns.Add(“عنوان درخواست”, typeof(string));
-
dtShow.Columns.Add(“کد درخواست”, typeof(int));
-
while (rdr.Read())
-
{
-
drShow = dtShow.NewRow();
-
drShow[“عنوان درخواست”] = rdr[“TypDesc”];
-
drShow[“کد درخواست”] = rdr[“TypCod”];
-
dtShow.Rows.Add(drShow);
-
dgView.DataSource = dtShow;
-
dgView.Columns[0].Width = 190;
-
}
-
}
-
}
Samaneh Hoghooghi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.