Easy Form Design at Run Time C# Winform

**
* Kindly view my Youtube Video Link to learn My Easy formDesign at Runtime. **

Design your Winform at Runtime.Perform CRUD operation to your Form at Runtime
with out writting any code using Stored Procedure.

In my previous article (Windows Form Design at Run Time)

I have explained about how to design form at runtime. I have extended the program to next advance version with more functionality. This is one of my best projects I have made. Hope you all like this. Now let’s see what’s new in my Easy Form Design @ Run Time

Limitation in my previous article:

In my previous article it has limitation like user needs to design and add code for events like binding grid and etc. 
user can load only one form. Adding parameter to SQL query is not possible.

New features in Easy Form Design at Run Time:

This has all my previous article features but with more new different functionality like.

1.       New program has 2 part 1st is Form View part where user can view all there dynamically created forms by selecting Menu from the tree view.

2.       2nd Form Design part is to Add New/Edit/Save and Open Form dynamically.

3.       User no needs to write any code.

4.       Easy form design.

5.       New Feature has options to select a Stored Procedure for their form.

6.       User can select parameter and select dynamic textbox control for parameter, which needs to be used in SQL server Stored Procedure.

7.       Save and Open Form.

The Easy Form Design at Run Time software application was developed to design your own Form using panel Control to, add Label, Button, TextBox, DataGridView and etc. User can select the Stored procedure which need to be used for the Form for example .Now user design there simple Search Form with a TextBox, Button and a Datagridview. For this user need to pass the Textbox as search parameter to Stored Procedure and the result need to be finally bound to Datagridview by clicking on the Button. In form design screen user can add a TextBox, Label, Button and DataGridView and from the Tools user can clicks on SQL Setting Tool Menu. User can select his Search Stored procedure and assign the controls to the parameter matching and finally save the form.

In main Form now user can able to view his saved Form Name in Tree view when he clicks on the menu. His saved form will be displayed .When user clicks on the button he can view all the details will be loaded from the data base using the Stored procedure which he or she has assign to the form. This simple C# application allows the user to add:

1.       Create New Form

2.       Save Form as XML file.

3.       Open Form from XML file.

4.       Cut, Copy, and Paste all controls.

5.       Delete All Control.

6.       Delete Selected Control.

7.       Add/Change Back Color for Form (Here Panel used as Form).

8.       Controls Bring to Front and Send to back options.

9.       Add **Label **Control and using Property window design the Label.

10.    Add **Button **Control and using Property window design the Button.

11.    Add **CheckBox **Control and using Property window design the CheckBox..

12.    Add **Button **Control and using Property window design the Button..

13.    Add **ComboBox **Control and using Property window design the ComboBox.

14.    Add **DataGridView **Control and using Property window design the DataGridView.

15.    Add **DataTimePicker **Control and using Property window design the DataTimePicker.

16.    Add Panel Control and using Property window design the ListBox.

17.    Add **PictureBox **Control and using Property window design the PictureBox.

18.    Add **RadioButton **Control and using Property window design the RadioButton.

19.    Add **TextBox **Control and using Property window design the TextBox.

20.    SQL Setting This is new feature in this application. Now user no needs to write any code here. You can write your Stored Procedure at your data base and using the SQL Setting tools menu, you can select your stored procedure for your form. Assign the controls property as parameter to the Stored Procedure.

21.    Bind/Insert/Edit and Delete Data from database using Stored Procedure.

New Easy Form Design has 5 Parts to design your From at Runtime.

1st Form View part

2nd Form Design part

3rd SQL Stored Procedure Setting for your Form

4th Save Form

5th open Existing Form to edit.

Now let’s see one by one in detail here.

Section 1st Form View part: In the below image I have pointed each part by Numbers.

1) When user clicks on “New Form Design” Button, Form will be open where users can Add, Edit, Open and Save Forms. We can see more detail in Form Design part.

2) In Tree view I will list all the saved Form Name. Whenever users create new Form and save. The saved filename will be listed in Treeview .When user click on Treeview Node related form will be loaded in right side.

3) Here for example we can see that, now user have clicked on “NewItem” from Treeview and the related form has been loaded. For this form I have selected the ItemInsert stored procedure and passed all the Textbox controls as parameter to the SP.

Here is the animated image which explains in more detail.

Section 2nd Form Design part:

In this Application we can see **Toolbar **at the Left which is used to add controls to Form (here our Panel).Center has a Form(Panel)  where user can add and design there controls. In the Right it has **Property **window which used to add all design to selected controls..

**Toolbar: **Here we can see all the list of controls which can be add to form at Runtime. Other features like Create New Form, Save Form, Open Form,Cupt,Copy and Paste Controls .At last control you can  see is the SQL Setting ,that is very important tool to set our form controls with Stored procedure to perform our CRUD Operations.

When user click on “New Form Design” Button the form design will be open. You can refer the above image for how the Design form looks. This form plays the main role for creating dynamic form at runtime. Here users can Add New, Edit, Open and Save Forms. In the above image I have pointed each part by Numbers.

1) In the Left side we have the Tool Menu where user can add Textbox, Label, Button ,Panel, DataGridView and etc at runtime to design the form.

2) User can design their Form here at runtime. User can drag and drop controls, resize controls.

3) Using the property grid users can change the property of each selected controls BackColor, FontColor, Text and etc.

4) This is to select Stored Procedure for a Form to perform CRUD Operation and set the parameter of SP with Controls. We will see detail about this part in Section 3rd part.

Easy Form Design at Run Time will allow users to Design Form at Run Time, Open and Save Form and reuse the existing Form. User can add controls at Runtime from the Toolbar, Design there Form, Select the Stored procedure, Match and add Parameters with controls to perform some Action like Select, Insert, Update and Delete.

Now for Example user can add a DataGridView and a Button Control at Run time with Textbox for search the User by UserCode and UserName.

Section 3rd SQL Stored Procedure Setting for your Form:

After we have design our form now it’s time to assign our Stored Procedure to our form and pass the control parameters to SP to perform CRUD Operations.

  To set the Stored Procedure and assign parameters to SP. Click the SQL Settings menu from Tool Bar.

When user clicks on the SQL Setting a new form will be open like below. In the below image I have marked as Numbers and let’s see each use one by one.

1)  In the Select Procedure Combo Box I will display all the Stored Procedure names from our Database. Note in our application Bin folder we can find the “DBConnection.txt” text file which has the default Database Connection String, user can change the default Connection string as per your database server Name, Database Name, SQL User id and PWD.

2) Once the Stored Procedure for our form is selected click the Parameter Button. Here we can see, I have selected the “USP_USER_SELECT” which will be used in our form to search and bind the user details.

3) When we click on parameter I will display all the parameter for the selected Stored Procedure. Note everything will be as dynamic so user no needs to add any parameter here. I will list all the parameter which is declared in Stored Procedure. If user needs to add or delete any parameter they can update their Stored Procedure and redesign the form here.

4) Select SQL parameter one by one and click the down arrow button. When user click on the Down arrow, SQL parameter will be displayed in parameter TextBox.

5) In Control Name List, I will display all the text Box control names which needs to be assign to each SQL parameter.

6) Same here select the appropriate control for the SQL parameter and click the No 6th down button. The Control Name will be added to the Control textbox.

7) Once the SQL parameter and Control has been selected click the Add Button one by one to add the final SQL parameter list which needs to be saved for our Form.

8) All the SQL Parameter for the Selected Stored Procedure will be added here.

9) Confirm the list and Click Ok to save the form.

Note -> Source Code Link : you can download the Complete Source code from** Source Code Download Link**