You tagged you post with SQL Server; what's the relation to?
In OO world you can use a Singleton to get a kind of globale variable: Implementing the Singleton Pattern in C#
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am making a software i want a global variable so that i can use across one form to other so basically i want to call roll no. that is written in an event datagridview row header event: Roll_No = Convert.ToInt32(bunifuDataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString()); this is the code and i want this Roll_no with its value on Form2.
You tagged you post with SQL Server; what's the relation to?
In OO world you can use a Singleton to get a kind of globale variable: Implementing the Singleton Pattern in C#
Hi Zeeshan Haider,
>that is written in an event datagridview row header event
What specific event did you execute it? And I made a test in dataGridView CellContentClick event you can refer to.
Form1.cs:
//Define global variables
public static int Roll_No;
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
Roll_No = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString());
}
Form2.cs
//Get value of Roll_No
int value = Form1.Roll_No;
Best Regards,
Daniel Zhang