GST Billing Software

header image

Open a Form through Custom Code

Erachana Line

46. How to open a form through custom code?

Kushal has a special feature where you can open any form through Custom Code, using Kushal Helper Classes.

The Code is as shown below -

Syntax

Form frm = ControlAdapter.CreateForm(formName);

frm.ShowDialog();

Example

Form frm = ControlAdapter.CreateForm("Customer_History");

frm.ShowDialog();

To Pass Parameter to same form


try

{// To Open the Customer History Form

if (!newRecord)

{

Form frm = ControlAdapter.CreateForm("Customer_History");

frm.SetPropertyValue("id", txt_cmn_customer_Id.Text);

frm.ShowDialog();

}

else

MessageBox.Show("Please Select the Customer");

}

catch (Exception exc)

{

MessageBox.Show("Unexpected error occured!" + Environment.NewLine + exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

}

Note : In the above code the parameter "id" is already created in "Customer_History" form. Its value can be passed from this text box "txt_cmn_customer_Id.Text".