System\Windows\Forms\Control.cs (125)
247private Control? _parent;
248private WeakReference<Control>? _reflectParent;
302/// Initializes a new instance of the <see cref="Control"/> class.
385/// Initializes a new instance of the <see cref="Control"/> class.
392/// Initializes a new instance of the <see cref="Control"/> class.
399/// Initializes a new instance of the <see cref="Control"/> class.
401public Control(Control? parent, string? text) : this()
408/// Initializes a new instance of the <see cref="Control"/> class.
410public Control(Control? parent, string? text, int left, int top, int width, int height) : this(parent, text)
782Control? parent = ParentInternal;
950Control? parent = ParentInternal;
1398if (container.ParentInternal is not Control parent
1621Control? control = ParentInternal;
2167Control topMost = TopMostParent;
2233Control? parent = ParentInternal;
2295Control control;
2302Control marshalingControl = FindMarshalingControl();
2346private static ISite? GetSitedParentSite(Control control)
2614public Control? Parent
2620internal virtual Control? ParentInternal
2692private Control? ReflectParent
2694get => _reflectParent?.TryGetTarget(out Control? parent) ?? false ? parent : null;
2699Control? existing = ReflectParent;
3145for (Control? control = this; control is not null; control = control.ParentInternal)
3189public Control? TopLevelControl => TopLevelControlInternal;
3191internal Control? TopLevelControlInternal
3195Control? control = this;
3205internal Control TopMostParent
3209Control control = this;
4145internal virtual void AssignParent(Control? value)
4284Control marshaler = FindMarshalingControl();
4338for (Control? ctl = this; ctl is not null; ctl = ctl._parent)
4353internal static void CheckParentingCycle(Control? bottom, Control? toFind)
4356Control? lastParent = null;
4358for (Control? ctl = bottom; ctl is not null; ctl = ctl.ParentInternal)
4391private void ChildGotFocus(Control child)
4404public bool Contains([NotNullWhen(true)] Control? ctl)
4583Control[] controlSnapshot = new Control[children.Count];
4586foreach (Control control in controlSnapshot)
4681/// Disposes of the resources (other than memory) used by the <see cref="Control"/>.
4743Control child = children[i];
4966Control marshaler = FindMarshalingControl();
5012Control? current = this;
5027private Control FindMarshalingControl()
5031Control? c = this;
5035Control? p = c.ParentInternal;
5136public static Control? FromChildHandle(IntPtr handle)
5141Control? control = FromHandle(hwnd);
5155/// it with the first parent <see cref="Control"/> if possible.
5163public static Control? FromHandle(IntPtr handle)
5212public Control? GetChildAtPoint(Point pt, GetChildAtPointSkip skipValue)
5223Control? control = FromChildHandle(hwnd);
5236public Control? GetChildAtPoint(Point pt) => GetChildAtPoint(pt, GetChildAtPointSkip.None);
5244Control? c = IsContainerControl ? ParentInternal : this;
5254private static bool IsFocusManagingContainerControl(Control ctl)
5353Control? control = this;
5384Control? ctl = FromHandle(hWndChild);
5406internal Control[] GetChildControlsInTabOrder(bool handleCreatedOnly)
5410foreach (Control c in Controls)
5420Control[] controls = new Control[holders.Count];
5429internal virtual Control? GetFirstChildControlInTabOrder(bool forward)
5436Control? found = null;
5512public Control? GetNextControl(Control? ctl, bool forward)
5523Control? found = ctl.GetFirstChildControlInTabOrder(forward: true);
5534Control? found = null;
5535Control? p = ctl._parent;
5597Control? found = null;
5598Control? parent = ctl._parent ?? throw new InvalidOperationException(
5618Control sibling = siblings[c];
5678Control? found = ctl.GetFirstChildControlInTabOrder(forward: false);
5695/// Return <see cref="Handle"/> if <paramref name="window"/> is a <see cref="Control"/>.
5701if (window is Control control)
5973Control marshaler = FindMarshalingControl();
6167protected void InvokePaint(Control c, PaintEventArgs e)
6172protected void InvokePaintBackground(Control c, PaintEventArgs e)
6183/// Returns <see langword="true"/> if <paramref name="descendant"/> is a descendant of this <see cref="Control"/>.
6185internal bool IsDescendant(Control? descendant)
6187Control? control = descendant;
6329private static bool IsScaledByParent(Control control)
6331Control? parentControl = control.Parent;
6387private object MarshaledInvoke(Control caller, Delegate method, object?[]? args, bool synchronous)
6560protected void InvokeOnClick(Control? toInvoke, EventArgs e)
6690internal virtual void OnChildLayoutResuming(Control child, bool performLayout)
6995Control? parent = ParentInternal;
7171Control child = children[i];
7556protected void InvokeGotFocus(Control? toInvoke, EventArgs e)
7717protected void InvokeLostFocus(Control? toInvoke, EventArgs e)
8047/// This is called in the <see cref="Control"/> constructor before calculating the initial <see cref="Size"/>.
8189Control? parent = ParentInternal;
8319for (Control? c = ParentInternal; c is not null; c = c.ParentInternal)
8357public void PerformLayout(Control? affectedControl, string? affectedProperty)
8473foreach (Control c in Controls)
8606/// on the <see cref="Control"/> referenced by the <paramref name="msg"/> <see cref="Message.HWnd"/>. It
8621internal static PreProcessControlState PreProcessControlMessageInternal(Control? target, ref Message message)
8768Control child = Controls[i];
8971Control? topMostParent = null;
9167Control?[]? controlSnapshot = null;
9180controlSnapshot = new Control[children.Count];
9183Control childControl = children[i];
9242Control? childControl = controlSnapshot[i];
9448Control child = children[i];
9565internal virtual void Scale(SizeF includedFactor, SizeF excludedFactor, Control requestingControl, bool causedByFontChanged = false)
9601internal void ScaleChildControls(SizeF includedFactor, SizeF excludedFactor, Control requestingControl, bool causedByFontChanged = false)
9610Control child = children[i];
9869public bool SelectNextControl(Control? ctl, bool forward, bool tabStopOnly, bool nested, bool wrap)
9871Control? nextSelectableControl = GetNextSelectableControl(ctl, forward, tabStopOnly, nested, wrap);
9883private Control? GetNextSelectableControl(Control? ctl, bool forward, bool tabStopOnly, bool nested, bool wrap)
9891Control? start = ctl;
9942((Control)c).SelectNextControl(this, true, true, true, true);
10434internal static AutoValidate GetAutoValidateForControl(Control control)
10835private void UpdateChildControlIndex(Control control)
10842if (this is TabControl || GetType() == typeof(Control))
10852Control? previousControl = FromHandle(hWnd);
10911private void UpdateChildZOrder(Control control)
10921Control child = Controls[i];
11096internal void WmContextMenu(ref Message m, Control sourceControl)
11136Control? control = FromHandle(m.LParamInternal);
12749Control? controlParent = ParentInternal;
12766void AddIfCreated(Control? control)
12825internal virtual ToolInfoWrapper<Control> GetToolInfoWrapper(TOOLTIP_FLAGS flags, string? caption, ToolTip tooltip)
System\Windows\Forms\ErrorProvider\ErrorProvider.cs (18)
17[ProvideProperty("IconPadding", typeof(Control))]
18[ProvideProperty("IconAlignment", typeof(Control))]
19[ProvideProperty("Error", typeof(Control))]
25private readonly Dictionary<Control, ControlItem> _items = [];
26private readonly Dictionary<Control, ErrorWindow> _windows = [];
428if (errBindings[j].Control is Control control)
473Dictionary<Control, string> controlError = new(bindingsCount);
478if (errBindings[j].Control is not Control control)
506foreach (KeyValuePair<Control, string> entry in controlError)
677return extendee is Control and not Form;
711private ControlItem EnsureControlItem(Control control)
727internal ErrorWindow EnsureErrorWindow(Control parent)
745public string GetError(Control control) => EnsureControlItem(control).Error;
754public ErrorIconAlignment GetIconAlignment(Control control) => EnsureControlItem(control).IconAlignment;
763public int GetIconPadding(Control control) => EnsureControlItem(control).IconPadding;
781public void SetError(Control control, string? value)
805public void SetIconAlignment(Control control, ErrorIconAlignment value)
813public void SetIconPadding(Control control, int padding)
System\Windows\Forms\Help\Help.cs (10)
22public static void ShowHelp(Control? parent, string? url)
30public static void ShowHelp(Control? parent, string? url, HelpNavigator navigator)
38public static void ShowHelp(Control? parent, string? url, string? keyword)
53public static void ShowHelp(Control? parent, string? url, HelpNavigator command, object? parameter)
69public static void ShowHelpIndex(Control? parent, string? url)
77public static unsafe void ShowPopup(Control? parent, string caption, Point location)
102private static unsafe void ShowHTML10Help(Control? parent, string? url, HelpNavigator command, object? param)
137HandleRef<HWND> handle = parent is not null ? (new(parent)) : Control.GetHandleRef(PInvoke.GetActiveWindow());
194private static void ShowHTMLFile(Control? parent, string? url, HelpNavigator command, object? param)
214HandleRef<HWND> handle = parent is not null ? new(parent) : Control.GetHandleRef(PInvoke.GetActiveWindow());
System\Windows\Forms\Help\HelpProvider.cs (24)
12[ProvideProperty("HelpString", typeof(Control))]
13[ProvideProperty("HelpKeyword", typeof(Control))]
14[ProvideProperty("HelpNavigator", typeof(Control))]
15[ProvideProperty("ShowHelp", typeof(Control))]
20private readonly Dictionary<Control, string?> _helpStrings = [];
21private readonly Dictionary<Control, bool> _showHelp = [];
22private readonly List<Control> _boundControls = [];
23private readonly Dictionary<Control, string?> _keywords = [];
24private readonly Dictionary<Control, HelpNavigator> _navigators = [];
55public virtual bool CanExtend(object? target) => target is Control;
63public virtual string? GetHelpKeyword(Control ctl)
75public virtual HelpNavigator GetHelpNavigator(Control ctl)
87public virtual string? GetHelpString(Control ctl)
98public virtual bool GetShowHelp(Control ctl)
109if (sender is not Control ctl)
123if (Control.MouseButtons != MouseButtons.None && !string.IsNullOrEmpty(helpString))
159if (sender is not Control ctl)
172public virtual void SetHelpString(Control ctl, string? helpString)
188public virtual void SetHelpKeyword(Control ctl, string? keyword)
204public virtual void SetHelpNavigator(Control ctl, HelpNavigator navigator)
218public virtual void SetShowHelp(Control ctl, bool value)
229internal bool ShouldSerializeShowHelp(Control ctl)
239public virtual void ResetShowHelp(Control ctl)
249private void UpdateEventBinding(Control ctl)
System\Windows\Forms\Layout\Containers\SplitContainer.cs (11)
64private Control? _nextActiveControl;
1537Control? group = this;
1803Control? parent = ParentInternal;
1825private bool SelectNextControlInContainer(Control? ctl, bool forward, bool tabStopOnly,
1906Control? parent = ParentInternal;
1928private bool SelectNextControlInPanel(Control? ctl, bool forward, bool tabStopOnly,
1995private static void SelectNextActiveControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap)
2026foreach (Control control in sc.Controls)
2031foreach (Control child in control.Controls)
2288internal override void AfterControlRemoved(Control control, Control oldParent)
System\Windows\Forms\Panels\TableLayoutPanel\TableLayoutPanel.cs (19)
11[ProvideProperty("ColumnSpan", typeof(Control))]
12[ProvideProperty("RowSpan", typeof(Control))]
13[ProvideProperty("Row", typeof(Control))]
14[ProvideProperty("Column", typeof(Control))]
15[ProvideProperty("CellPosition", typeof(Control))]
177obj is Control control && control.Parent == this;
183public int GetColumnSpan(Control control) =>
186public void SetColumnSpan(Control control, int value)
197public int GetRowSpan(Control control) => _tableLayoutSettings.GetRowSpan(control);
199public void SetRowSpan(Control control, int value)
212public int GetRow(Control control) => _tableLayoutSettings.GetRow(control);
215public void SetRow(Control control, int row)
227public TableLayoutPanelCellPosition GetCellPosition(Control control) =>
231public void SetCellPosition(Control control, TableLayoutPanelCellPosition position) =>
240public int GetColumn(Control control) => _tableLayoutSettings.GetColumn(control);
243public void SetColumn(Control control, int column)
252public Control? GetControlFromPosition(int column, int row) =>
253(Control?)_tableLayoutSettings.GetControlFromPosition(column, row);
255public TableLayoutPanelCellPosition GetPositionFromControl(Control? control) =>
System\Windows\Forms\ToolTip\ToolTip.cs (73)
13[ProvideProperty(nameof(ToolTip), typeof(Control))]
36private readonly Dictionary<Control, TipInfo> _tools = [];
41private Control? _topLevelControl;
50private readonly Dictionary<HWND, Control> _owners = [];
69private readonly HashSet<Control> _created = [];
149internal string? GetCaptionForTool(Control tool)
305if (window is Control control &&
475private Control? TopLevelControl
484Control? currentTopLevel = null;
485Control[] controls = [.. _tools.Keys];
488var control = controls[i];
617private void AnnounceText(Control? tool, string text)
636Control control = (Control)sender!;
645Control control = (Control)sender!;
676public bool CanExtend(object target) => target is Control;
793Control[] controls = [.. _tools.Keys];
794foreach (Control control in controls)
802Control[] controls = [.. _tools.Keys];
803foreach (Control control in controls)
815private void SetToolInfo(Control control, string? caption)
843private void CreateRegion(Control control)
869if (sender is not Control control)
897private void DestroyRegion(Control control)
913new ToolInfoWrapper<Control>(control).SendMessage(this, PInvoke.TTM_DELTOOLW);
972private unsafe ToolInfoWrapper<Control> GetTOOLINFO(Control control, string? caption)
1002return new(Control.GetSafeHandle(window), flags);
1012public string? GetToolTip(Control? control)
1030Control? current = TopLevelControl;
1039Control? currentControl = Control.FromHandle(hwndControl);
1073current = Control.FromHandle(found);
1076current = Control.FromChildHandle(found);
1093Control? control = Control.FromHandle(hwnd);
1147Control[] controls = [.. _tools.Keys];
1148foreach (Control control in controls)
1205public void SetToolTip(Control control, string? caption)
1214private void SetToolTipInternal(Control control, TipInfo info)
1247ToolInfoWrapper<Control> toolInfo = GetTOOLINFO(control, info!.Caption);
1266private void SetToolTipToControl(Control associatedControl)
1309if (window is Control associatedControl)
1409PInvokeCore.GetWindowRect(Control.GetSafeHandle(window), out var r);
1429PInvokeCore.GetWindowRect(Control.GetSafeHandle(window), out var r);
1447PInvokeCore.GetWindowRect(Control.GetSafeHandle(window), out var r);
1465PInvokeCore.GetWindowRect(Control.GetSafeHandle(window), out var r);
1502if ((tool is Control toolAsControl && _tools.TryGetValue(toolAsControl, out TipInfo? tipInfo)) ||
1503(ownerWindow is Control ownerWindowAsControl && _tools.TryGetValue(ownerWindowAsControl, out tipInfo)))
1532ToolInfoWrapper<HandleRef<HWND>> info = new(Control.GetSafeHandle(ownerWindow));
1729if (win is Control control && control.IsDisposed)
1737ToolInfoWrapper<HandleRef<HWND>> info = new(Control.GetSafeHandle(win));
1745if (win is not Control tool)
1783Control[] controls = [.. _owners.Values];
1792Control? tool = window as Control;
1795ToolInfoWrapper<Control> toolInfo = new(tool);
1830if (window is Control windowAsControl)
1961ToolInfoWrapper<Control> toolInfo = default;
1970private Control? GetCurrentToolWindow()
1973return _owners.TryGetValue(hwnd, out Control? control) ? control : Control.FromHandle(hwnd);
1982if (window is not Control windowAsControl || !_tools.TryGetValue(windowAsControl, out TipInfo? tipInfo))
2007PInvokeCore.GetWindowRect(Control.GetSafeHandle(window), out var r);
2043Control? toolControl = window as Control;
2157if (window is Control windowAsControl && !_tools.TryGetValue(windowAsControl, out tipInfo))
2231if (window is not Control control || !_tools.TryGetValue(control, out TipInfo? tipInfo))
2337font = Control.DefaultFont;
2340Control? control = window as Control ?? Control.FromHandle(window.Handle);