Kushal Tutorials - Document

Desktop App Builder Kushal| Form-Wise Control Property

Apply Business Logic using Expressions


Expression editor enables you to write your own code or logic and assigns it to the particular events of Controls or forms.

To open the Expression editor window, select a form and click on the Expression Button. Please note that each expression created is tightly associated with the selected form.

To Create the Expressions

To add a new expression click on the Add Button.

The Add button opens a window, where the user can choose to name the expression and decide whether the expression needs to return a Boolean value (True, False) as the return parameter. A new expression gets added to the Expression list.

To rename the Expression name Click on Edit button

To get a return value from the expression, check the checkbox Return True/False. By choosing this option, an expression has to return either true or false. A compilation error message will be generated if the given expression does not return any value when the user has explicitly checked in the checkbox.

Click Save.

Write the code on the right-side window, where you can use IntelliSense to aid in writing the program logic.

Click Delete.

To delete the Expressions added click on the delete button.

Compile Expression

To check the compilation errors in the user-defined code, click on the Compile Expression Button. If any errors are found in the written code, the Compiler will list those errors. After solving the errors user gets this message.

To associate the expression on particular Control event, select the Set Control/Form Expression.

The Expression Association window is shown

All the Controls which are used in the particular form are displayed.

Select the Control from List of Controls list box.

When you select the Control from the list, all the Controls related events are listed in the Control Events Listbox.

Select the events to be associated with the expression, by using the arrow buttons -

>> Button will choose all events of the given Control and

<< Button will remove the events from the Selected Events list box.

You can reorder the event's sequence.

Select an event from the Selected Event list.

Click on Update Association Button.

Select the Expressions from Choose Expression list.

To select multiple expressions at a time, hold the Ctrl (Control) key, then select the Expressions.

In addition to this, the user can also change the order of execution of expressions.

Associate Expression to events list displays all associated expressions to the particular Control Event.

Click on Show Association Button.
It will display all the associated Expressions for the respective events.

Click Close.

Show Association

Click on Show Association Button.

All the Controls which are associated with Expressions for the respective events are displayed.

Preview Code

To Preview the code, Click on Preview Code Button.

This option displays the source code of the selected Form. Using this feature, you can see the Kushal generated code of the selected Form.

Refer Document No. 17(Preview Code before Generating C# Solution)for further details regarding the usage of Preview Code.

Show the Last Message

Click on Show Last Message Button

Shows Compilation Error Messages and the Name of respective form and associated button.

Click on Copy To Clipboard Button

Helps to copy the compilation Messages to any clipboard.

Global Variables

Click on Global Variables button to add global variables.

Click on Add Button
Click on Save then Close the form

Refer to Document No. 13(Defining Global Variables) for further details regarding the usage of Global Variables.

Additional Expression Editor

• The Additional Expression editor option is provided in case if you want to add additional Partial class for each form.

Click on Additional Expression button.

To add the Default code, click on the Default code Button.

Click on Query Builder to Create a query and execute it. Refer Document No. 20 for further details regarding the Query Builder Usage.

Enter the additional functions with parameters, reusable code, Enum constants, etc. that

you wanted to add and Click on Compile Expression to compile the code. Click on Save.

Then click Save.


This option is used to add external references to your project.

To add an external reference, Click on the Add Reference Button. Select a *.dll file from the system path.

The selected References file displays all the methods and functions which are listed in the Reference window.

To add an external reference, Click on the Add Reference Button, Select *.dll file from system path and click Open.

Then you can use the DLL functions in Expressions that you build.

Report File

Click on Reports tab and Click Add Report to add reporting files to the Kushal project.

Selected files are automatically copied to project path\bin\Reports folder when output project is compiled.


Click on the Classes tab and Click Add to add classes to the Kushal project.

Click on Save to Save the Classes added or attached.

To Remove the added classes, click on Remove Button.

To download the particular class, select the class and click on Download Button.

To Attach Class file Click on Attach Class (Copy Class) Button

Kushal contains a set of Classes with built-in functionality. Following are the few important classes with their functions.

Aggregate Functions

These Functions or Methods are used to calculate the sum, count, max, min values in the Data Grid.

  1. AggregateFunctionEvaluator.CalculateAvg

Eg: AggregateFunctionEvaluator.CalculateAvg (DataGrid Name, "Column_Name");
Description: Returns the average value of the column, resulting in a positive or negative value.

  1. AggregateFunctionEvaluator.CalculateCount

Eg: AggregateFunctionEvaluator.CalculateCount (DataGrid Name, "Column_Name");
Description: Returns the Number of rows in the Data Grid, always resulting in a positive number.

  1. AggregateFunctionEvaluator.CalculateMax

Eg: AggregateFunctionEvaluator.CalculateMax (DataGrid Name, "Column_Name");
Description: Returns the Maximum value of the column. The result is a positive or negative value.

  1. AggregateFunctionEvaluator.CalculateMin

Eg: AggregateFunctionEvaluator.CalculateMin (DataGrid Name, "Column_Name");
Description: Returns the Minimum value of the column. The result is a positive or negative value.

  1. AggregateFunctionEvaluator.CalculateSum

Eg: AggregateFunctionEvaluator.CalculateSum (DataGrid Name, "Column_Name");
Description: Returns the total of the column, resulting in a positive or negative value.

  1. AggregateFunctionEvaluator.Equals

Eg: AggregateFunctionEvaluator.Equals (object A, object B);
Description: Returns a Boolean value. It checks both objects and if they are equal, returns True, otherwise returns False.

  1. AggregateFunctionEvaluator.FirstValue

Eg: AggregateFunctionEvaluator.CalculateFirstValue (DataGrid Name, "Column_Name");
Description: Returns the First Value of the Data Grid column, resulting in a String.

  1. AggregateFunctionEvaluator.LastValue

Eg: AggregateFunctionEvaluator.CalculateLastValue(DataGrid Name, "Column_Name");
Description: Returns the Last Value of the Data Grid column, resulting in a String.


These Functions or Methods are used to associate Controls to Grids and update the SQL Statement that fills the list of the content displayed on the Controls. While most ControlAdapter functions contain an aspect of Control placed on a Form, not all functions are associated explicitly with Controls or SQL while serving to still update some aspect of the Form.

  1. ControlAdapter.AssociateSelectAllListbox

Eg: ControlAdapter.AssociateSelectAllListbox(CheckBox,CheckedListBox)
Description: It is used to associate all items selected in the Listbox Control

  1. ControlAdapter.CalculatedColumn

Eg: ControlAdapter.CalculatedColumn(Action<DataGridView>, DataGridView obj)
Description: It is used to calculate the column values in the Grid. It creates the delegate function to a particular Grid column and returns the result.

  1. ControlAdapter.ClearGridRows

Eg: ControlAdapter.ClearGridRows(DataGrid name)
Description: Clears all the rows in the given Data Grid.

  1. ControlAdapter.CloseContainerForm

Eg: ControlAdapter.CloseContainerForm(Control Name)
Description: Closes the form by associated Control.

  1. ControlAdapter.Filter

Eg: ControlAdapter.Filter(dataGrid name, "dataGrid column name")
Description: Filters the result of given Control (Data Grid, list box, Combo Box) based on the condition given.

  1. ControlAdapter.GetColumnName

Eg: ControlAdapter.GetColumnName(dataGrid name, "dataGrid coloumn name")
Description: Returns the name of the Data Grid column.

  1. ControlAdapter.LoadTreeView

Eg: ControlAdapter.LoadTreeView();
Description: Loads Treeview Control and updates associated Grid and Controls.

  1. ControlAdapter.MoveNodeDown

Eg: ControlAdapter.MoveNodeDown();
Description: Moves selected tree node down and updates associated Grid and Controls.

  1. ControlAdapter.MoveNodeLeft

Eg: ControlAdapter.MoveNodeLeft();
Description: Moves selected tree node left and updates associated Grid and Controls.

  1. ControlAdapter.MoveNodeRight

Eg: ControlAdapter.MoveNodeRight()
Description: Moves selected tree node right and updates associated Grid and Controls.

  1. ControlAdapter.MoveNodeUp

Eg: ControlAdapter.MoveNodeUp()
Description: Moves selected tree node upwards and updates associated Grid and Controls

  1. ControlAdapter.ProcessColumnValidation

Eg: ControlAdapter.ProcessColumnValidation();
Description: Handles Grid column events and performs Grid column validations given.

  1. ControlAdapter.ProcessDropdownColumns

Eg: ControlAdapter.ProcessDropdownColumns()
Description: Handles few events of dropdown Control and process their values based on the conditions provided.

  1. ControlAdapter.RearrageNode

Eg: ControlAdapter.RearrageNode()
Description: Rearranges tree nodes based on the direction provided and also updates associated Grid and Controls.

  1. ControlAdapter.ResetControl

Eg: ControlAdapter.ResetControls();
Description: Resets Controls and set their values to a default value if provided.

  1. ControlAdapter.SaveTreeView

Eg: ControlAdapter.SaveTreeView();
Description: Save Treeview Control and updates associated Grid and Controls.

  1. ControlAdapter.ShowDialog

Eg: ControlAdapter.ShowDialog(Form Name)
Description: Display the Form as a dialog box.

  1. ControlAdapter.ShowImage

Eg: ControlAdapter.ShowImage("Imagepath", picturebox_name)
Description: Display the Image in a particular image box.

  1. ControlAdapter.ShowTooltip

Eg: ControlAdapter.ShowTooltip("Message",Control name)
Description: Shows tooltip to the particular Control.

  1. ControlAdapter.ValidateDateTime

Eg: ControlAdapter.ValidateDateTime()
Description: Validates the given date from the input.


This is used to directly execute SQL statement to affect Database Table entries with no ties to any Controls.

  1. SqlInterpreter.ExecuteSQL

Eg: SqlInterpreter.ExecuteSQL("query")
Description: Execute the SQL query which does not return any value. It is used in cases where we are not interested in the output of Insert or Update queries.

  1. SqlInterpreter.GetData

Eg: SqlInterpreter.GetData("Query")
Description: Get data in data table format for the given query.

  1. SqlInterpreter.GetScalarData

Eg: SqlInterpreter.GetScalarData("String");
Description: Returns set of values for the given query. Returns single set of values (null by default).