Monday 18 November 2013

Visible/invisible Fields using Checkbox

If you face requirement of Visible/invisible Fields using Checkbox this post will help you. It is very simple process that i am showing in briefly step by step.
First we have to create a table that contain some fields according to figure 1 and have to keep in mind  that one field should be Enum Type and set its property “EnumType NoYesCombo”.

Figure 1 - Create a table with “Enum Type” field

Next, create a form according to figure 2 and set following property:
1. “Student_checkBox”
AutoDeclaration - “Yes”
DataSource – “Student”
DataField - “Fee”
2. Student_StudentId
AutoDeclaration - “Yes”
3. Student_Name
      AutoDeclaration - “Yes”

Figure 2 – Create form and override modified()

Finally, override “modified()” method on Student_CheckBox with following code:

public boolean modified()
{
    boolean ret;

    ret = super();
    if(Student_CheckBox.checked())
    {
        Student_StudentId.visible(false);
        Student_Name.visible(false);
     }
    else
    {
        Student_StudentId.visible(true);
        Student_Name.visible(true);
    }
    return ret;
}

Figure 3 - Result

No comments:

Post a Comment