Click here to Skip to main content
15,867,330 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
coursecontrol form by clicking btn_emp serachform will open
C#
private void Btn_Emp_Click(object sender, EventArgs e)
       {
           serachfrom1 sa = new serachfrom1();
           sa.ShowDialog();

       }



by clicking select button in gridview it trasfer data to textboxes in coursecontrol form


C#
private void Tsb_Select_Click_1(object sender, EventArgs e)
       {
           cousecontrol cr = new cousecontrol();
           cr.Show();


       }
Posted
Updated 22-Jul-14 18:28pm
v2
Comments
navya chowdary 23-Jul-14 0:01am    
i am not geeting solution for this,plz help me

There are many way to transfer data from one form to second one Please let me know do you have windows form or asp.net form ?
if you are using asp.net form then
you can use
server.transfer

You can pass information between pages in various ways, some of which depend on how the redirection occurs. The following options are available even if the source page is in a different ASP.NET Web application from the target page, or if the source page is not an ASP.NET Web page:

Use a query string.

Get HTTP POST information from the source page.

The following options are available only when the source and target pages are in the same ASP.NET Web application.

Use session state.

Create public properties in the source page and access the property values in the target page.

Get control information in the target page from controls in the source page.


If You are using windows form then

Using constructor
Using objects
Using properties
Using delegates
 
Share this answer
 
Comments
navya chowdary 23-Jul-14 1:46am    
i am using windows forms,grid view selected data transfer to textbox in another form,do u now any examaple pojects
Manoj Kumar Choubey 23-Jul-14 3:09am    
http://www.c-sharpcorner.com/UploadFile/scottlysle/PassData01142007013005AM/PassData.aspx


http://www.codeproject.com/Articles/17371/Passing-Data-between-Windows-Forms

http://www.codeproject.com/Articles/14122/Passing-Data-Between-Forms
Manoj Kumar Choubey 23-Jul-14 3:09am    
Please check above links as example
Manoj Kumar Choubey 23-Jul-14 3:10am    
as I listed four methods
navya chowdary 24-Jul-14 7:25am    
tqqqqqqq......
in form 1 write this code

C#
using(Form2 form2 = new Form2())
{
  if(form2.ShowDialog() == DialogResult.OK)
  {
    someControlOnForm1.Text = form2.TheValue;
  }
}


and in form form 2 write this code
C#
//Create a public property to serve the value
public string TheValue
{
  get { return someTextBoxOnForm2.Text; }
}
 
Share this answer
 
Comments
navya chowdary 25-Jul-14 1:58am    
it's not working sir...i already tried it
chaitanya556 25-Jul-14 2:02am    
for what purpose you are writing this code? i mean what exactly you want to do with this code?
chaitanya556 25-Jul-14 2:00am    
did you tried by Googleing?
As the question turned out to be very popular, and my previous answers often were not well understood, probably were not clear enough, I decided to write a Tips/Trick article complete with detailed code samples and explanations: Many Questions Answered at Once — Collaboration between Windows Forms or WPF Windows.

—SA
 
Share this answer
 
You can use a static class with a static property and set the value from first from and get the value at second form.

C#
public static class Common 
{
public static string GridValue {get;set;}
}
 
Share this answer
 
Comments
navya chowdary 24-Jul-14 7:25am    
tqqq.....
Suvabrata Roy 24-Jul-14 7:48am    
tqqq... mean ?
TarunKumarSusarapu 25-Jul-14 1:32am    
Its not a c# code it means "thank you"
Suvabrata Roy 25-Jul-14 1:40am    
C# is lot easier to understand :) thanks for the explanation
navya chowdary 25-Jul-14 2:04am    
wht it means??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900