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 8703597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:54:12+00:00 2026-06-13T02:54:12+00:00

Using MDI and Child Forms Code. childform_load Me.MdiParent = MDIMain ‘ Private Sub form1_KeyDown(ByVal

  • 0

Using MDI and Child Forms

Code.

childform_load

Me.MdiParent = MDIMain

‘

 Private Sub form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
     If e.KeyCode = Keys.Escape Then
         Me.Close()
     End If
 End Sub

The above code is working for MDI Form (form name is mdiform1), but not working for child form1, when I press the escape key, it is closing the MDI Form instead of Child form.

I check the Child Form Name also, name is form1 only.

What was the problem, i need to change any property of child form.

Need code help

  • 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-13T02:54:13+00:00Added an answer on June 13, 2026 at 2:54 am

    This works for me

    Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
            If e.KeyCode = Keys.Escape Then
                For Each child As Form In Me.MdiParent.MdiChildren
                    child.Close()
                Next child
            End If
        End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using VB6 Using MDI Forms, sub Forms also When I run the Software in
How do I close (using code) the last created CView in my MDI app.
I've been using the factory model to create child forms to add to a
Loading multiple child forms from a loop into a MDI parent form. They are
I am writing an MDI application in C# that contains two child forms which
I have a WinForm app that has other child forms (not mdi). If the
Possible Duplicate: Setting popup window to be a child of MDI Control when using
So, I'm writing a text editor, using MDI. I have a frame window, child
I have these forms: MainScreen - MDI container DataBaseOutput - child NewAnime - child
Microsoft seems to want us to stop using the MDI, but if more people

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.