OnControlChange
IPDFDocument4 :: Annotations

See Also Example
Collapse All

This property gets or sets a JavaScript action to be performed when the value of another field changes, thus recalculating the value of the current field.

Syntax

LONG OnControlChange { get; set; }
Value
Number of the action

Remarks

The number of the action can be retrieved by using the CreateJavaScriptAction method.

Example

Handling OnAnnotChange

Delphi
[copy to clipboard]
{ PDF object is supposed to be created }
a1 := PDF.CreateJavascriptAction('this.getField("edit1").value = "edit2 is changed!";');
a2 := PDF.CreateJavascriptAction('this.getField("edit2").value = "edit1 is changed!";');

PDF.AddEditBox(10, 10, 100, 24, 'edit1');
PDF.AnnotUnicodeText := 'Edit1';
PDF.OnAnnotChange := a2;

PDF.AddEditBox(10, 30, 100, 44, "edit2');
PDF.AnnotUnicodeText := 'Edit2';
PDF.OnAnnotChange := a1;

PDF.SaveToFile('test.pdf', true);
C/C++
[copy to clipboard]
// PDF object is supposed to be created
long a1 = PDF->CreateJavascriptAction("this.getField('edit1').value = 'edit2 is changed!';");
long a2 = PDF->CreateJavascriptAction("this.getField('edit2').value = 'edit1 is changed!';");

PDF->AddEditBox(10, 10, 100, 24, "edit1");
PDF->AnnotUnicodeText = L"Edit1";
PDF->OnControlChange = a2;

PDF->AddEditBox(10, 30, 100, 44, "edit2");
PDF->AnnotUnicodeText = L"Edit2";
PDF->OnControlChange = a1;

PDF->SaveToFile("test.pdf", true);
C#
[copy to clipboard]
// PDF object is supposed to be created
long a1 = PDF.CreateJavascriptAction("this.getField('edit1').value = 'edit2 is changed!';");
long a2 = PDF.CreateJavascriptAction("this.getField('edit2').value = 'edit1 is changed!';");

PDF.AddEditBox(10, 10, 100, 24, "edit1");
PDF.AnnotUnicodeText = "Edit1";
PDF.OnControlChange = a2;

PDF.AddEditBox(10, 30, 100, 44, "edit2");
PDF.AnnotUnicodeText = "Edit2";
PDF.OnControlChange = a1;

PDF.SaveToFile("test.pdf", true);
Visual Basic
[copy to clipboard]
' PDF object is supposed to be created
a1 = PDF.CreateJavascriptAction("this.getField('edit1').value = 'edit2 is changed!';")
a2 = PDF.CreateJavascriptAction("this.getField('edit2').value = 'edit1 is changed!';")

PDF.AddEditBox 10, 10, 100, 24, "edit1"
PDF.AnnotUnicodeText = "Edit1"
PDF.OnControlChange = a2

PDF.AddEditBox 10, 30, 100, 44, "edit2"
PDF.AnnotUnicodeText = "Edit2"
PDF.OnControlChange = a1

PDF.SaveToFile "test.pdf", true

See Also

Reference