// in RTL, we parent a transparent control over the grip to support mirroring. private void EnsureRightToLeftGrip() { if (SizingGrip && RightToLeft == RightToLeft.Yes) { RTLGrip.Bounds = SizeGripBounds; if (!this.Controls.Contains(RTLGrip)) { WindowsFormsUtils.ReadOnlyControlCollection controlCollection = this.Controls as WindowsFormsUtils.ReadOnlyControlCollection; if (controlCollection != null) { controlCollection.AddInternal(RTLGrip); } } } else if (rtlLayoutGrip != null) { if (this.Controls.Contains(rtlLayoutGrip)) { WindowsFormsUtils.ReadOnlyControlCollection controlCollection = this.Controls as WindowsFormsUtils.ReadOnlyControlCollection; if (controlCollection != null) { controlCollection.RemoveInternal(rtlLayoutGrip); } rtlLayoutGrip.Dispose(); rtlLayoutGrip = null; } } }
private void EnsureRightToLeftGrip() { if (this.SizingGrip && (this.RightToLeft == RightToLeft.Yes)) { this.RTLGrip.Bounds = this.SizeGripBounds; if (!base.Controls.Contains(this.RTLGrip)) { WindowsFormsUtils.ReadOnlyControlCollection controls = base.Controls as WindowsFormsUtils.ReadOnlyControlCollection; if (controls != null) { controls.AddInternal(this.RTLGrip); } } } else if ((this.rtlLayoutGrip != null) && base.Controls.Contains(this.rtlLayoutGrip)) { WindowsFormsUtils.ReadOnlyControlCollection controls2 = base.Controls as WindowsFormsUtils.ReadOnlyControlCollection; if (controls2 != null) { controls2.RemoveInternal(this.rtlLayoutGrip); } this.rtlLayoutGrip.Dispose(); this.rtlLayoutGrip = null; } }
// Ensures the hosted Control is parented to the ToolStrip hosting this ToolStripItem. private void SyncControlParent() { WindowsFormsUtils.ReadOnlyControlCollection newControls = GetControlCollection(ParentInternal); if (newControls != null) { newControls.AddInternal(Control); } }
private void SyncControlParent() { WindowsFormsUtils.ReadOnlyControlCollection controlCollection = GetControlCollection(base.ParentInternal); if (controlCollection != null) { controlCollection.AddInternal(this.Control); } }
protected override void OnParentChanged(ToolStrip oldParent, ToolStrip newParent) { if (((oldParent != null) && (base.Owner == null)) && ((newParent == null) && (this.Control != null))) { WindowsFormsUtils.ReadOnlyControlCollection controlCollection = GetControlCollection(this.Control.ParentInternal as ToolStrip); if (controlCollection != null) { controlCollection.RemoveInternal(this.Control); } } else { this.SyncControlParent(); } base.OnParentChanged(oldParent, newParent); }
/// <include file='doc\ToolStripControlHost.uex' path='docs/doc[@for="ToolStripControlHost.OnParentChanged"]/*' /> /// <devdoc> /// Called when the item's parent has been changed. /// </devdoc> protected override void OnParentChanged(ToolStrip oldParent, ToolStrip newParent) { if (oldParent != null && Owner == null && newParent == null && Control != null) { // if we've really been removed from the item collection, // politely remove ourselves from the control collection WindowsFormsUtils.ReadOnlyControlCollection oldControlCollection = GetControlCollection(Control.ParentInternal as ToolStrip); if (oldControlCollection != null) { oldControlCollection.RemoveInternal(Control); } } else { SyncControlParent(); } base.OnParentChanged(oldParent, newParent); }
private static WindowsFormsUtils.ReadOnlyControlCollection GetControlCollection(ToolStrip toolStrip) { WindowsFormsUtils.ReadOnlyControlCollection newControls = toolStrip != null ? (WindowsFormsUtils.ReadOnlyControlCollection)toolStrip.Controls : null; return(newControls); }