Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4061344
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:27:20+00:00 2026-05-20T15:27:20+00:00

I have created a User Control in my application that has a textbox and

  • 0

I have created a User Control in my application that has a textbox and then 2 buttons on it. One button is to Add data to the DB from the textbox and the second Cancels the action. This User Control is then added to multiple Dialogs (forms) but I want the buttons to trigger the same events, which the reason I placed the buttons on the User Control and not the Dialog.

What I am trying to do is after they click the Add data button and it is successful, I want it to close the Dialog that the control is located on.

EDIT:

I don’t know how to go about coding this to close the Dialog when it is triggered from a User Control. I don’t know where to start because I haven’t used User Controls before. Typically I just have the controls on a Dialog which allows for the DialogResult = DialogResult.OK;

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T15:27:21+00:00Added an answer on May 20, 2026 at 3:27 pm

    Forms opened modally will close automatically when their DialogResult is set. From the sounds of it, you are setting the DialogResult of the control, not the form. To do what are you are trying to do, you need the control to set or trigger the setting of the parent forms dialog result. You can do this by either:

    1. Passing through a reference of the form to the control, which
    allows the control to set it.

    2. Create an event on the control that the forms listens to,
    which tells it to close. (recomemnded way)

    3. (The hacky way) Set the forms dialog result using this code:

    this.ParentForm.DialogResult = DialogResult.OK;
    

    The form will also need to be shown modally, otherwise you will need to call the Close() method manually.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created an application that runs in the taskbar. When a user clicks
I have created a textbox in a Windows Forms application that starts out at
I have a very basic application that has buttons in a toolstrip. When a
In my application I have a user control that do async operations using thread
I have created a user control to handle adding comments to certain business entities,
I have created a UserControl that has a ListView in it. The ListView is
I have some UserControls that I created in ProjectA. I have ProjectB that has
I have a form that is dynamically created. It is a winForms application. This
I have an existing application that has some parts of formatted text-blocks (standard formats
I have an application that is installed on Vista PC's by a user with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.