如何从其他表单的组合框中显示其他表单中的数据?

时间:2016-12-20 05:48:48

标签: c# winforms

我有两种形式,分别为Frm_DepartmentFrm_Employee

如何将文本框(Frm_Department)中的数据传输到ComboBox(Frm_Employee)?下面的图片是我从TextBox传输数据的地方。

以下是表格。

enter image description here

表格部门代码:

if (txtDepname.Text != "" && txtDepLocation.Text != "" && txtDepLocal.Text != "" )
{
    DataClasses1DataContext db = new DataClasses1DataContext();
    tbldepartment dep = new tbldepartment();
    dep.DepID = txtDepID.Text;
    dep.Depname = txtDepname.Text;
    dep.Location = txtDepLocation.Text;
    dep.LocalPhone = txtDepLocal.Text;
    Insert.sp_insertdepartment(dep);
    MessageBox.Show("Successfully Saved!");
    AutoGenerate();
}
else
{
    MessageBox.Show("Input all Details....");
}

表格员工代码:

if (txtempLname.Text != "" && txtempFname.Text != "" && txtempMname.Text != "" && txtempPossition.Text != "")
{
    DataClasses1DataContext db = new DataClasses1DataContext();
    tblemployee emp = new tblemployee();
    emp.EmpID = txtempnum.Text;
    emp.Lname = txtempLname.Text;
    emp.Fname = txtempFname.Text;
    emp.Mname = txtempMname.Text;
    emp.Position = txtempPossition.Text;
    Insert.sp_insertemployee(emp);
    MessageBox.Show("Successfully Saved!");
    AutoGenerate();
}
else
{
    MessageBox.Show("Input all Details....");
}

0 个答案:

没有答案