suite4.net.FormDatabase Documentation

IForm.SetComponentValue Method 

Sets the value of a designated property of a component contained in the IForm.

[Visual Basic]
Sub SetComponentValue( _
   ByVal componentName As String, _
   ByVal propertyName As String, _
   ByVal value As Object _
)
[C#]
void SetComponentValue(
   string componentName,
   string propertyName,
   object value
);

Parameters

componentName
The component's name.
propertyName
The name of the property.
value
The value to be set.

Exceptions

Exception Type Condition
ArgumentNullException An argument is null (Nothing in Visual Basic).
LoaderException The component with the name can't be found in the IForm or the property can't set to the provided value.

Example

The following example demonstrates how to serialize an IForm and display an alert to the user.

C# sample

using System;
using System.Collections;
using suite4.net.FormDatabase;
using suite4.net.Sample;
namespace suite4.net.Web.Sample
{
    public class FormServer : System.Web.Services.WebService
    {
        [System.Web.Services.WebMethod]
        public string SerializeForm(string formName)
        {
            string                    projectFileName;
            IForm                        form;
            IProject                project;
            ArrayList                employees;
            WebLoaderAlert    webLoaderAlert;

            projectFileName = this.Server.MapPath("\\sample")  "\\sample.fspj";
            project = Project.LoadFromFile(projectFileName);
            if(project != null)
            {
                form = project.GetForm(formName);
                if(form != null)
                {
                    employees = new ArrayList();
                    employees.Add("Anne Dodsworth");
                    employees.Add("Laura Callahan");
                    employees.Add("Robert King");
                    form.SetComponentValue("lstEmployees", "Items", employees);
                    webLoaderAlert = new WebLoaderAlert();
                    webLoaderAlert.Title = "Select an employee";
                    webLoaderAlert.Message = "Please select an employee\nto see the employee details.";
                    return form.SerializeToSwfXml(null, webLoaderAlert);
                }
                else
                {
                    webLoaderAlert = new WebLoaderAlert();
                    webLoaderAlert.Title = "Failed to load form";
                    webLoaderAlert.Message = "Can't find form "  formName;
                    return webLoaderAlert.SerializeToSwfXml();
                }
            }
            else
            {
                webLoaderAlert = new WebLoaderAlert();
                webLoaderAlert.Title = "Failed to load project";
                webLoaderAlert.Message = "Can't find project\n"  projectFileName;
                return webLoaderAlert.SerializeToSwfXml();
            }
        }
    }
}
            

VB.Net sample
Imports System
Imports System.Collections
Imports suite4.net.FormDatabase
Imports suite4.net.Sample
Namespace suite4.net.Web.Sample
    Public Class FormServer
     Inherits System.Web.Services.WebService
        <System.Web.Services.WebMethod> _
        Public Function SerializeForm(ByVal formName As String) As String
            Dim projectFileName As String
            Dim form As IForm
            Dim project As IProject
            Dim employees As ArrayList
            Dim webLoaderAlert As WebLoaderAlert

            projectFileName = Me.Server.MapPath("\\sample")  "\\sample.fspj"
            project = Project.LoadFromFile(projectFileName)
            If Not project Is Nothing Then
                form = project.GetForm(formName)
                If Not form Is Nothing Then
                    employees = New ArrayList()
                    employees.Add("Anne Dodsworth")
                    employees.Add("Laura Callahan")
                    employees.Add("Robert King")
                    form.SetComponentValue("lstEmployees", "Items", employees)
                    webLoaderAlert = New WebLoaderAlert()
                    webLoaderAlert.Title = "Select an employee"
                    webLoaderAlert.Message = "Please select an employee\nto see the employee details."
                    Return form.SerializeToSwfXml(Nothing,webLoaderAlert)
                Else
                    webLoaderAlert = New WebLoaderAlert()
                    webLoaderAlert.Title = "Failed to load form"
                    webLoaderAlert.Message = "Can't find form "  formName
                    Return webLoaderAlert.SerializeToSwfXml()
                End If
            Else
                webLoaderAlert = New WebLoaderAlert()
                webLoaderAlert.Title = "Failed to load project"
                webLoaderAlert.Message = "Can't find project\n"  projectFileName
                Return webLoaderAlert.SerializeToSwfXml()
            End If
        End Function
    End Class
End Namespace

            

See Also

IForm Interface | suite4.net.FormDatabase Namespace