Custom dialog box in C#?

后端 未结 5 2058
执笔经年
执笔经年 2021-02-20 17:19

I have a button that when clicked, a dialog box opens up with various controls on it such as radio buttons and text boxes. If OK then the values in that dialog box is passed ba

5条回答
  •  死守一世寂寞
    2021-02-20 17:54

    One way would be to create an event in your dialog form. Depending on how many values you want to send back then you can just have parameters in the event delegate. A better way is to create a small class or struct for arguments containing a list of properties that you want to return.

    If you click OK then you fire the event with the values from the dialog. For cancel the event is not fired.

    In the form with the button you hook up a handler for the event. This receives your values and you may then do with them whatever you need to.

    http://msdn.microsoft.com/en-us/library/aa645739(v=vs.71).aspx

提交回复
热议问题