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

  • SEARCH
  • Home
  • 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 8241467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:50:48+00:00 2026-06-07T20:50:48+00:00

I have made a custom dialog window that inherits ChildWindow public partial class InputWindow

  • 0

I have made a custom dialog window that inherits ChildWindow

public partial class InputWindow : ChildWindow
{
    public InputWindow()
    {
        InitializeComponent();
    }

    private void OKButton_Click(object sender, RoutedEventArgs e)
    {
        MessageBox.Show("clicked");
    }

    private void CancelButton_Click(object sender, RoutedEventArgs e)
    {
        this.DialogResult = false;
    }

    private void inputTextBox_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.Key == Key.Enter)
            this.OKButton_Click(this, new RoutedEventArgs());
    }
}

When I press enter in the tetxbox the event OKButton_Click gets fired ( because message box appears). However, the code (Add Folder) in the event handler below that exists in another class does not get fired! even though the message box appears! Why is this so? and How can I fix it?

InputWindow win = new InputWindow();
win.Title = "Enter New Folder Name";
win.OKButton.Click += (s, e) =>
{
    if (!string.IsNullOrWhiteSpace(win.inputTextBox.Text))
    {
        AddNewFolder(win.inputTextBox.Text);
        win.DialogResult = true;
    }
};
win.Show();
  • 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-06-07T20:50:49+00:00Added an answer on June 7, 2026 at 8:50 pm

    You’re just calling OKButton_click directly from your KeyDown event handler. That’s not the same as raising the Click event on the OK button itself – it’s just a method call. So it’s no wonder that other event handlers for OKButton.Click aren’t being called.

    I don’t know of any way of manually raising the Click event yourself. It sounds like really you should have one common method which is called from both the Click event handler and the KeyDown event handler.

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

Sidebar

Related Questions

I have made the custom dialog for my application. @Override public void onCreate(Bundle savedInstanceState)
I have a custom-made view that extends the View class. I would like 2
I have a JTable with custom TableCellRenderer. public class DateCellRenderer extends DefaultTableCellRenderer { private
I have made a custom textbox that inherits from textbox. using System.Drawing; using System;
I have some custom made dialog that have on it Set Button , I
I have made my custom In extension method as shown below: public static class
I have made a custom class by inheriting a DateTimePicker and made some methods
I have a custom made dialog winform. On it I have a label, textbox
I have made some custom attached properties that enable me to create a pop
I have made a custom block in Magento that contains some JS. I want

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.