简体   繁体   中英

C# Devexpress How to Pass Multiple Value from WinForm 1 to WinForm 2 ? (To perform New,Edit, View and so on)

I try to pass multiple values from WinForm1 to WinForm2 (To perform New,Edit, View and so on).

WinFrom1 Name : PayrollConfigNation

DataTable :tableMaster ( bind with gridView1 )

Column Name : NationalCode - nvarchar(20), NationalCountry - nvarchar(50), GovermentCode - nvarchar(50), Remakrs - nvarchar(50), Note - ntext, IsActive - d_Boolean(char(1))

/// WinForm1 Code : PayrollConfigNation
public partial class PayrollConfigNation : DevExpress.XtraEditors.XtraForm
{
    private BCE.Data.DBSetting mydbset;
    private DataTable tableMaster;
    private DataSet loadData = new DataSet();
    public PayrollConfigNation(BCE.Data.DBSetting DBSet)
    {
        InitializeComponent();
        mydbset = DBSet;
        ConfigureGridViewColumns(); // Define gridView1 column
        InitializeGridViewControl();
        LoadDataFunction();
    }
    ..........
    private void btnNew_Click(object sender, EventArgs e)
    {
        PayrollBBNationalForm myForm2 = new PayrollBBNationalForm(); 
        myForm2.Show();
    }

WinForm1布局:PayrollConfigNation I want transfer all WinForm1(PayrollConfigNation) focused row column value (tableMaster) to WinForm2(PayrollBBNationalForm) which is the entry detail screen to perform Edit, View or even New function.

WinFrom2 Name : PayrollBBNationalForm

/// WinFrom2 Code : PayrollBBNationalForm
public partial class PayrollBBNationalForm : DevExpress.XtraEditors.XtraForm
{
    private BCE.Data.DBSetting mydbset;
    public PayrollBBNationalForm()
    {
        InitializeComponent();
    }
}

WinFrom2布局:PayrollBBNationalForm

I am stuck at this level, I have no idea whether should I code passing the dataSet/dataTable (tableMaster) parameter or the focus row column value parameter. I try few experiment code, unfortunately all fail so far.

I manage to pass the parameter between WinForm1 to WinForm2.

I still seeking is there any better solution and nicer to code the parameter (I am still new to c# programming environment)?

winFrom1 Code

    int focusrow;
    focusrow = gridView1.FocusedRowHandle;
    PayrollBBNationalForm myForm2 = new PayrollBBNationalForm(tableMaster, gridView1, "New", focusrow);

winForm2 Code

    public PayrollBBNationalForm(DataTable tableMaster, GridView gridView1, String mode, int row)
    {
        InitializeComponent();
        tableMasterForm = tableMaster;
        gridView1Form = gridView1;
        modeForm = mode;
        rowForm = row;
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM