开发者

switch between forms on ironpython studio

I'm new to IronPython, currently using ironpython studio, usually I like to program with Visual Basic or Delphi. My problem is that I don't know how to switch between forms by clicking a button, on Delphi you normaly write this code from a button on "form1":

procedure TMain.buttonClick(Sender: TObject);
begin
    form2.show;
end;

in VB you usually开发者_如何转开发 write almost the same thing, I'd like to know how to do this in Ironpython studio, I'd be grateful if somebody could help me, thanks!


You'd have to add a handler to the button's click event (like you would in C# and not like in VB) and show the other form. Refer to a C# tutorial for reference, it will be very similar in IronPython. Or better yet, try to learn about the differences between C#, IronPython, and VB and Delphi.

The button's Click event takes two parameters. As long as the function takes two parameters (not including the implicit self), you're set.

e.g.,

class MyForm(Form):
    def __init__(self):
        # create a form with a button
        button = Button()
        button.Text = 'Click Me'
        self.Controls.Add(button)

        # register the _button_click() method to the button's Click event
        button.Click += self._button_Click

    def _button_Click(self, sender, e):
        # do what you want to do
        Form2().Show() # create an instance of `Form2` and show it
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜