English 中文(简体)
VB. NET 防止MDI 父母从闭门后入门 检查前的儿童
原标题:VB.NET Prevent MDI Parent FormClosing from Closing MDI Child before check

我试图让用户有机会取消MDI父母的表态,把一个“你肯定吗?”的ms箱放在一个电子背书上,然而,当MDI父母援引表格时,所有MDI儿童首先在ms箱出现之前就关闭了。

我很想知道,在我得到积极反应以结束并进而把所有近亲事件推向儿童之前,防止儿童关闭,而不是强迫每个儿童戴头巾是否容易。

EDIT: I guess the only solution I can find is adding If e.CloseReason = CloseReason.MdiFormClosing Then e.Cancel = True to the FormClosing event and using ApplicationExit instead.

最佳回答
If e.CloseReason = CloseReason.MdiFormClosing Then
   e.Cancel = True
End If

如果你能够从事申请工作。 每当你打着香料,就会停用。

问题回答

父母的起步

    frmMdiChild1.MdiParent = Me
    frmMdiChild1.Show()

Add Formclos Sub

Private Sub frmMdiChild1_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
    If e.CloseReason = CloseReason.UserClosing Then
        e.Cancel = True
    End If
End Sub

@Theveloper: 我尝试了。 MdiFormClosing, but it don t work. 为了查明什么用途,我是一名CloseReason女士。 而且,只有例如Cancel = 真实性,才能防止父母关闭(离婚)。

(vb.net 2010)

普通学校 变式

Public Shared mdi_main As mdiMain

初中

进口系统:Windows.Forms

公共学校

Public forced_close As Boolean = False

Private Sub mdiMain_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
    e.Cancel = True
    If MsgBox("Are you sure you want to exit?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
          Close all child forms of the parent.
        For Each ChildForm As Form In Me.MdiChildren
            ChildForm.Close()
        Next
        e.Cancel = False
    End If
End Sub

初中

Public Class frmMember

Private Sub frmMember_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
    Select Case e.CloseReason
        Case CloseReason.UserClosing
            e.Cancel = True
            If Not clsGlobalVariables.mdi_main.forced_close Then
                If MsgBox("Are you sure you want to close?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
                    e.Cancel = False
                End If
            End If
        Case Else
            clsGlobalVariables.mdi_main.forced_close = True
            e.Cancel = True
    End Select
End Sub

初中





相关问题
Is Shared ReadOnly lazyloaded?

I was wondering when I write Shared ReadOnly Variable As DataType = New DataType() Or alternatively Shared ReadOnly Variable As New DataType() Is it lazy loaded or as the instance initializes? ...

Entertaining a baby with VB.NET

I would like to write a little application in VB.NET that will detect a baby s cry. How would I get started with such an application?

Choose Enter Rather than Pressing Ok button

I have many fields in the page and the last field is a dropdown with list of values. When I select an item in a dropdown and press Enter, it doesn t do the "Ok". Instead I have to manually click on Ok ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

Set Select command in code

On button Click I want to Set the Select command of a Gridview. I do this and then databind the grid but it doesn t work. What am i doing wrong? protected void bttnView_Click(object sender, ...

Hover tooltip on specific words in rich text box?

I m trying to create something like a tooltip suddenly hoovering over the mouse pointer when specific words in the richt text box is hovered over. How can this be done?

热门标签