Hi
This is Tarun.
I want to copy data from one user control to another after clicking select button.
When ever we click on Dark triangle button in User control 1 then it displays user
control 2 and when ever we select the row in a Datagridview and select select button
then it displays corresponding column values in the textboxes in the 1st user control.
I have written this code.But no use.
In User Control 2 in select button:name is Employeesearch.cs
public void btn_Select_Click(object sender, EventArgs e)
{
DataGridViewRow dr = DGV_Summary.SelectedRows[0];
DGV_Summary.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
Work wrk = new Work();
wrk.EId1 = Convert.ToInt32(dr.Cells[0].Value.ToString());
wrk.EName1 = dr.Cells[1].Value.ToString();
wrk.Paygrade1= dr.Cells[2].Value.ToString();
wrk.PayPeriod1= dr.Cells[3].Value.ToString();
wrk.LoadData();
this.ParentForm.Close();
}
In User Control 1 In Loaddata method:Name is Work.cs
namespace WorkExperience
{
public partial class Work : UserControl
{
private int EmpId;
public int EId1
{
get { return EmpId; }
set { EmpId = value; }
}
private string EName;
public string EName1
{
get { return EName; }
set { EName = value; }
}
private string Paygrade;
public string Paygrade1
{
get { return Paygrade; }
set { Paygrade = value; }
}
private string Payperiod;
public string PayPeriod1
{
get { return Payperiod; }
set { Payperiod = value; }
}
public Work()
{
InitializeComponent();
}
public void LoadData()
{
Txt_EmpCode.Text = Convert.ToString(EId1);
Txt_EmpName.Text = EName;
Txt_Pay.Text = Paygrade;
ddl_PayPeriod.SelectedItem = Payperiod;
}