I have created a user control in my application that contains a text box and then there are 2 buttons from a button text box to DB Add data and cancel the second operation. This user control is then added to more than one dialog (form), but I want to trigger the same events in the button, due to which I placed the button on user control and did not communicate.
What am I trying to do, after clicking on the Add data button and it has succeeded, I want to close the dialog which is located on the control.
Edit:
I do not know how to go about coding to turn off dialog when user starts with control. I do not know where it starts from because I have not used user control before, usually I have control over only one dialog which is thanks when their dialogs are set The form will automatically close. With its sounds, you are setting the control dialogue dialog, not the form. To do what you are trying to do, you need control to set or trigger settings of parental forms dialogue results. You can do it either: 1. Passing through a reference to the form for control, which allows the control to set it up. 2. Create an event on such controls, which listen to the form, which asks to close it. (Referred route) 3. (hack way) Set the form dialog result using this code: The form will also need to be shown ideologically, otherwise you will need to manually call off () method. DialogResult = DialogResult.OK;
this.ParentForm.DialogResult = DialogResult.OK;
Comments
Post a Comment