Using VSA with WinForms -
06-09-2004
, 12:22 PM
I've a Winforms application that I want to add some
scripting capabilities to, using VSA.
I've a running app and can invoke methods in my script,
but I want the user to define event handlers for
controls on the form.
The way I use is to predefine event handlers in my
code and invoke the methode in the script then:
Button b = new Button();
b.Name = "ScriptButton";
b.Click += new EventHandler(script_Event);
private void script_Event(object sender, EventArgs e)
{
// look for a method "ScriptButton_Click" and invoke
}
This works, but it seems really complicated. The Script
I use does contain definitions like
Private Sub ScriptButton_Click(sender As Object, e As EventArgs) _
Handles Click
' Do something on Click
End Sub
And the Button is added as Object.
If I Run() the VsaEngine, nothing happens (obviously, cause
I invoke nothing).
Question:
How can I use the Scriptengine as event handler vor an
existing form? How can I interact betwenn the form and the
scripting code? Is there any way to operate the script as
part of the form, e.g. invoke ShowDialog() of my form from
within the script and deal with the form as I can from my
main app?
Thanks for any idea
Joerg |