DataGridview in Windows application

Posted by Lokeshbasana under C# on 5/10/2009 | Views : 6012 | Status : [Member] | Replies : 5
how to pass datagridview values from one form to another using dataGridView1_CellClick

Form2.cs

private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
string field = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();

// how to pass above Field value to Form3
}

Please send me solution
Thank u




Responses

Posted by: Vinay13mar on: 10/20/2012 [Member] Starter | Points: 25
Posted by: Vuyiswamb on: 5/10/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
There are no global variables in C#, use static variables instead:

C/C++:


int Global = 10;
.
Global = 20;

C#:
public class Foo
{

public static int Global = 10;

}



...



Foo.Global = 20;


Thank you for Posting at dotnetfunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Lokeshbasana, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lokeshbasana on: 5/11/2009 [Member] Starter

Up
0
Down
Thank u Vuyiswamb your solution solve my problem.

Its really good solution for passing variables from one form to another form using winform application.

Lokeshbasana, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 5/11/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Good Morning Lokeshbasana

You are Welcome

Thank you for Posting at Dotnetfunda


Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Lokeshbasana, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Neeks on: 5/13/2009 [Member] Bronze

Up
0
Down
You can use FOr Web Application
Response.Redirect("~/Form3.aspx?val =" + dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString());


You can get the value by Reques.QueryString["val"]

For window you can use Static Class

Lokeshbasana, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response