Create a basic form with a textedit of type date inside

Paolo Manfrin

The attached customize rule creates a menu under Help > Sample Form that displays a really basic form with one label, one textedit (of type date) and a button.


Once the button is pressed the input date is written on the statusbar.


The form will be rendered as in the attached picture.


 


The code inside the customize rule is the following:



try
{
Form fInput = Form.CreateNewForm("FInput", SwissAddonFramework.Utils.UniqueStringGenerator.Next());
fInput.Width = 500;
fInput.Height = 110;
fInput.Left = 500;
fInput.Top = 500;

// create a label
Label label = Label.CreateNew("L1");
label.Left = 5;
label.Top = 20;
label.Width = 250;
label.Value = "Date of the credit card statements:";
fInput.AddItem(label);

// crate a datasource for the textEdit (to specify that the text edit should be a date field)
UserDatasource dateDS = UserDatasource.CreateNew("DATEDS");
dateDS.DataSourceType = UserDatasource.DataType.Data;
DataBind dateDB = DataBind.CreateNew(dateDS.UniqueID);
dateDB.DataBound = true;
fInput.AddUserDatasource(dateDS);

// create a text edit
TextEdit dateTxt = TextEdit.CreateNew("T1");
dateTxt.Left = label.Left + label.Width + 5;
dateTxt.Width = 100;
dateTxt.Top = label.Top;
dateTxt.DataBind = dateDB;
fInput.AddItem(dateTxt);

Button btnOK = Button.CreateNew("1");
btnOK.Left = label.Left;
btnOK.Top = label.Top + label.Height + 5;
//btnOK.Value = "OK";
fInput.AddItem(btnOK);
fInput.DefButton = "1";
fInput.Load();


SwissAddonFramework.UI.EventHandling.ItemEvents.ItemPressedEventHandler ItemPressedEv = null;
ItemPressedEv = delegate(SwissAddonFramework.UI.EventHandling.ItemEvents.ItemPressed ev)
{
try
{
// handler when the button "OK" is pressed
StatusBar.WriteSucess(dateTxt.Value);
fInput.Close();
}
catch (Exception innerException)
{
StatusBar.WriteError("InnerException @ " + pVal.RuleInfo.RuleName + " : " + innerException.Message);
}
};
btnOK.AddHandler_ItemPressed(SwissAddonFramework.UI.Components.ModeComponent.FormModes.ALL, null, ItemPressedEv);

}
catch (Exception ex)
{
StatusBar.WriteError(ex.Message);
}


M.Zurbrüggen

Hi Paolo,


 


thank you for this. This helps me a lot.


BUT: i want to place a Texteditfield on the new form wich references on a existing UDF.


My plan is: Create a new form, place a Textedit-Field on this new Form.


If this field was filled and i click on update, the inputted value should be saved in a existig UDF.


How can i realise that?



0

Comments

0 comments

Please sign in to leave a comment.

Didn't find what you were looking for?

New post