Sunday, September 27, 2015

PowerForms update – 0.3.5.3906

If you are new to PowerForms then please checkout previous posts about PowerForms here and here.  This post explains about a new update to PowerForms 0.3.5.3906 which you can download through nuget.  So let’s dive into few new features added to PowerForms.

1. Adding ListBoxFor support to PowerForms and it is similar to how you would use ComboBoxFor

            var form = new PowerForm();
var dt = form.ListBoxFor("Fruits", new string[] { "Apple", "Orange" }).Display();

System.Console.WriteLine(dt["Fruits"].ToString());

System.Console.Read();

2. Adding SelectedIndexChanged event support for ComboBox and ListBoxFor

            var form = new PowerForm();
var dt = form.ListBoxFor("Fruits", new string[] { "Apple", "Orange" }, (o,e) =>
{
System.Console.WriteLine("Inside SelectedIndexChanged Event");
}).Display();

System.Console.WriteLine(dt["Fruits"].ToString());

System.Console.Read();

3.  Adding ButtonFor support. Earlier if you wanted to submit information second time you would have to close the form and run the program again. With ButtonFor you can now add your own Button for which you can specify a custom click action. On the click event you can do other things with the form, for example new GetFormOutput method on the form which gives you the same dictionary<string, object> for submitted form values. You can also close the PowerForm using form.Close() method added to form inside the click event.

	  var form = new PowerForm();

var dt = form.TextBoxFor("FirstName")
.ButtonFor("Click me", (object o, EventArgs e) =>
{
var rs = form.GetFormOutput();
System.Console.WriteLine(rs["FirstName"].ToString());
form.Close();
}).Display();

System.Console.WriteLine(dt["FirstName"].ToString());
System.Console.Read();


4. Adding CheckBoxFor support allows you to add a CheckBox to the form. It gives you out as a boolean if the field is checked or not.

 
var form = new PowerForm();

var dt = form.CheckBoxFor("Yes")
.CheckBoxFor("No")
.Display();
System.Console.WriteLine(dt["Yes"].ToString());
System.Console.WriteLine(dt["No"].ToString());
System.Console.Read();

5. You can now tell the form not to include the default Submit button if you wish to inside the SubmitButton method.

            var form = new PowerForm();

var dt = form.TextBoxFor("FirstName")
.SubmitButton(false).Display();

dt["FirstName"].ToString().ToConsole();
System.Console.Read();

No comments:

Post a Comment