Difference between .Owner property and ShowDialog(IWin32Window owner)?

后端 未结 1 972
陌清茗
陌清茗 2021-02-06 02:19

I presume a winform\'s owner can be set explicitly via the .Owner property OR by passing the owner in the overloaded method ShowDialog(IWin32Window owne

1条回答
  •  逝去的感伤
    2021-02-06 03:17

    Looking at the differences of these 2 options using Reflector, it seems that they have a slightly different implementation: box.Owner = this just assign the provided value of this to the internal owner field. However, when calling ShowDialog(IWin32Window), the implementation performs the following call, prior to assigning the value:

    owner = ((Control) owner).TopLevelControlInternal;
    

    This might result in assignment of the MDIParent.

    (Note: I'm far from being an expert regarding MDI, so I might be wrong here).

    0 讨论(0)
提交回复
热议问题