System\Windows\Forms\Components\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 = [];
420if (errBindings[j].Control is Control control)
465Dictionary<Control, string> controlError = new(bindingsCount);
470if (errBindings[j].Control is not Control control)
498foreach (KeyValuePair<Control, string> entry in controlError)
671return extendee is Control and not Form;
702private ControlItem EnsureControlItem(Control control)
718internal ErrorWindow EnsureErrorWindow(Control parent)
736public string GetError(Control control) => EnsureControlItem(control).Error;
745public ErrorIconAlignment GetIconAlignment(Control control) => EnsureControlItem(control).IconAlignment;
754public int GetIconPadding(Control control) => EnsureControlItem(control).IconPadding;
772public void SetError(Control control, string? value)
796public void SetIconAlignment(Control control, ErrorIconAlignment value)
804public void SetIconPadding(Control control, int padding)
System\Windows\Forms\Components\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\Control.cs (145)
260private Control? _parent;
261private WeakReference<Control>? _reflectParent;
312/// Initializes a new instance of the <see cref="Control"/> class.
406/// Initializes a new instance of the <see cref="Control"/> class.
413/// Initializes a new instance of the <see cref="Control"/> class.
421/// Initializes a new instance of the <see cref="Control"/> class.
423public Control(Control? parent, string? text) : this()
430/// Initializes a new instance of the <see cref="Control"/> class.
432public Control(Control? parent, string? text, int left, int top, int width, int height) : this(parent, text)
506/// of Control inheritance in WinForms. The constructor of <see cref="Control"/> calls <see cref="CreateParams"/>,
513/// and related logic may be triggered during the base <see cref="Control"/> construction process, before the
1064Control? parent = ParentInternal;
1232Control? parent = ParentInternal;
1673if (container.ParentInternal is not Control parent
1896Control? control = ParentInternal;
2442Control topMost = TopMostParent;
2508Control? parent = ParentInternal;
2570Control control;
2577Control marshalingControl = FindMarshalingControl();
2621private static ISite? GetSitedParentSite(Control control)
2889public Control? Parent
2895internal virtual Control? ParentInternal
2967private Control? ReflectParent
2969get => _reflectParent?.TryGetTarget(out Control? parent) ?? false ? parent : null;
2974Control? existing = ReflectParent;
3420for (Control? control = this; control is not null; control = control.ParentInternal)
3464public Control? TopLevelControl => TopLevelControlInternal;
3466internal Control? TopLevelControlInternal
3470Control? control = this;
3480internal Control TopMostParent
3484Control control = this;
4451internal virtual void AssignParent(Control? value)
4596Control marshaler = FindMarshalingControl();
4649for (Control? ctl = this; ctl is not null; ctl = ctl._parent)
4664internal static void CheckParentingCycle(Control? bottom, Control? toFind)
4667Control? lastParent = null;
4669for (Control? ctl = bottom; ctl is not null; ctl = ctl.ParentInternal)
4702private void ChildGotFocus(Control child)
4715public bool Contains([NotNullWhen(true)] Control? ctl)
4894Control[] controlSnapshot = new Control[children.Count];
4897foreach (Control control in controlSnapshot)
4992/// Disposes of the resources (other than memory) used by the <see cref="Control"/>.
5054Control child = children[i];
5277Control marshaler = FindMarshalingControl();
5331Control? current = this;
5346private Control FindMarshalingControl()
5350Control? c = this;
5354Control? p = c.ParentInternal;
5455public static Control? FromChildHandle(IntPtr handle)
5460Control? control = FromHandle(hwnd);
5474/// it with the first parent <see cref="Control"/> if possible.
5482public static Control? FromHandle(IntPtr handle)
5531public Control? GetChildAtPoint(Point pt, GetChildAtPointSkip skipValue)
5542Control? control = FromChildHandle(hwnd);
5555public Control? GetChildAtPoint(Point pt) => GetChildAtPoint(pt, GetChildAtPointSkip.None);
5563Control? c = IsContainerControl ? ParentInternal : this;
5573private static bool IsFocusManagingContainerControl(Control ctl)
5673Control? control = this;
5704Control? ctl = FromHandle(hWndChild);
5726internal Control[] GetChildControlsInTabOrder(bool handleCreatedOnly)
5730foreach (Control c in Controls)
5740Control[] controls = new Control[holders.Count];
5749internal virtual Control? GetFirstChildControlInTabOrder(bool forward)
5756Control? found = null;
5832public Control? GetNextControl(Control? ctl, bool forward)
5843Control? found = ctl.GetFirstChildControlInTabOrder(forward: true);
5854Control? found = null;
5855Control? p = ctl._parent;
5917Control? found = null;
5918Control? parent = ctl._parent ?? throw new InvalidOperationException(
5938Control sibling = siblings[c];
5998Control? found = ctl.GetFirstChildControlInTabOrder(forward: false);
6015/// Return <see cref="Handle"/> if <paramref name="window"/> is a <see cref="Control"/>.
6021if (window is Control control)
6295Control marshaler = FindMarshalingControl();
6489protected void InvokePaint(Control c, PaintEventArgs e)
6494protected void InvokePaintBackground(Control c, PaintEventArgs e)
6505/// Returns <see langword="true"/> if <paramref name="descendant"/> is a descendant of this <see cref="Control"/>.
6507internal bool IsDescendant(Control? descendant)
6509Control? control = descendant;
6651private static bool IsScaledByParent(Control control)
6653Control? parentControl = control.Parent;
6709private object MarshaledInvoke(Control caller, Delegate method, object?[]? args, bool synchronous)
6882protected void InvokeOnClick(Control? toInvoke, EventArgs e)
7012internal virtual void OnChildLayoutResuming(Control child, bool performLayout)
7145Control.ControlCollection children,
7531Control source,
7548Control control,
7562private Control Control { get; }
7578public VisualStylesModeChangeEventArgs CreateForControl(Control control)
7598Control control,
7632public void RequestLayout(Control? target, Control cause)
7652public void RequestAncestorLayouts(Control? target, Control cause)
7654for (Control? current = target; current is not null; current = current.ParentInternal)
7660private static int GetLayoutDepth(Control control)
7664for (Control? parent = control.ParentInternal; parent is not null; parent = parent.ParentInternal)
7673Control source,
7679public Control Source { get; } = source;
7688public VisualStylesModeLayoutRequest(Control target, Control cause)
7695public Control Cause { get; }
7697public Control Target { get; }
7738Control? parent = ParentInternal;
7914Control child = children[i];
8311protected void InvokeGotFocus(Control? toInvoke, EventArgs e)
8469protected void InvokeLostFocus(Control? toInvoke, EventArgs e)
9053Control? parent = ParentInternal;
9183for (Control? c = ParentInternal; c is not null; c = c.ParentInternal)
9221public void PerformLayout(Control? affectedControl, string? affectedProperty)
9337foreach (Control c in Controls)
9470/// on the <see cref="Control"/> referenced by the <paramref name="msg"/> <see cref="Message.HWnd"/>. It
9485internal static PreProcessControlState PreProcessControlMessageInternal(Control? target, ref Message message)
9632Control child = Controls[i];
9835Control? topMostParent = null;
10034Control?[]? controlSnapshot = null;
10047controlSnapshot = new Control[children.Count];
10051Control childControl = children[i];
10111Control? childControl = controlSnapshot[i];
10332Control child = children[i];
10449internal virtual void Scale(SizeF includedFactor, SizeF excludedFactor, Control requestingControl, bool causedByFontChanged = false)
10485internal void ScaleChildControls(SizeF includedFactor, SizeF excludedFactor, Control requestingControl, bool causedByFontChanged = false)
10494Control child = children[i];
10750public bool SelectNextControl(Control? ctl, bool forward, bool tabStopOnly, bool nested, bool wrap)
10752Control? nextSelectableControl = GetNextSelectableControl(ctl, forward, tabStopOnly, nested, wrap);
10764private Control? GetNextSelectableControl(Control? ctl, bool forward, bool tabStopOnly, bool nested, bool wrap)
10772Control? start = ctl;
10823((Control)c).SelectNextControl(this, true, true, true, true);
11329internal static AutoValidate GetAutoValidateForControl(Control control)
11730private void UpdateChildControlIndex(Control control)
11737if (this is TabControl || GetType() == typeof(Control))
11747Control? previousControl = FromHandle(hWnd);
11806private void UpdateChildZOrder(Control control)
11816Control child = Controls[i];
11991internal void WmContextMenu(ref Message m, Control sourceControl)
12031Control? control = FromHandle(m.LParamInternal);
13653Control? controlParent = ParentInternal;
13670void AddIfCreated(Control? control)
13729internal virtual ToolInfoWrapper<Control> GetToolInfoWrapper(TOOLTIP_FLAGS flags, string? caption, ToolTip tooltip)
System\Windows\Forms\Controls\Buttons\ButtonInternal\DarkMode\ButtonDarkModeRendererBase.cs (1)
107Control control,
System\Windows\Forms\Controls\Buttons\ButtonInternal\DarkMode\IButtonRenderer.cs (1)
44Control control,
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)
140HandleRef<HWND> handle = parent is not null ? (new(parent)) : Control.GetHandleRef(PInvoke.GetActiveWindow());
197private static void ShowHTMLFile(Control? parent, string? url, HelpNavigator command, object? param)
217HandleRef<HWND> handle = parent is not null ? new(parent) : Control.GetHandleRef(PInvoke.GetActiveWindow());
System\Windows\Forms\Layout\Containers\SplitContainer.cs (11)
64private Control? _nextActiveControl;
1537Control? group = this;
1812Control? parent = ParentInternal;
1834private bool SelectNextControlInContainer(Control? ctl, bool forward, bool tabStopOnly,
1915Control? parent = ParentInternal;
1937private bool SelectNextControlInPanel(Control? ctl, bool forward, bool tabStopOnly,
2004private static void SelectNextActiveControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap)
2035foreach (Control control in sc.Controls)
2040foreach (Control child in control.Controls)
2297internal 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 (75)
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;
723PInvoke.SetWindowTheme(HWND, $"{Control.DarkModeIdentifier}_{Control.ExplorerThemeIdentifier}", null);
797Control[] controls = [.. _tools.Keys];
798foreach (Control control in controls)
806Control[] controls = [.. _tools.Keys];
807foreach (Control control in controls)
819private void SetToolInfo(Control control, string? caption)
847private void CreateRegion(Control control)
873if (sender is not Control control)
901private void DestroyRegion(Control control)
917new ToolInfoWrapper<Control>(control).SendMessage(this, PInvoke.TTM_DELTOOLW);
976private unsafe ToolInfoWrapper<Control> GetTOOLINFO(Control control, string? caption)
1006return new(Control.GetSafeHandle(window), flags);
1016public string? GetToolTip(Control? control)
1034Control? current = TopLevelControl;
1043Control? currentControl = Control.FromHandle(hwndControl);
1077current = Control.FromHandle(found);
1080current = Control.FromChildHandle(found);
1097Control? control = Control.FromHandle(hwnd);
1151Control[] controls = [.. _tools.Keys];
1152foreach (Control control in controls)
1209public void SetToolTip(Control control, string? caption)
1218private void SetToolTipInternal(Control control, TipInfo info)
1251ToolInfoWrapper<Control> toolInfo = GetTOOLINFO(control, info!.Caption);
1270private void SetToolTipToControl(Control associatedControl)
1313if (window is Control associatedControl)
1413PInvokeCore.GetWindowRect(Control.GetSafeHandle(window), out var r);
1433PInvokeCore.GetWindowRect(Control.GetSafeHandle(window), out var r);
1451PInvokeCore.GetWindowRect(Control.GetSafeHandle(window), out var r);
1469PInvokeCore.GetWindowRect(Control.GetSafeHandle(window), out var r);
1506if ((tool is Control toolAsControl && _tools.TryGetValue(toolAsControl, out TipInfo? tipInfo)) ||
1507(ownerWindow is Control ownerWindowAsControl && _tools.TryGetValue(ownerWindowAsControl, out tipInfo)))
1536ToolInfoWrapper<HandleRef<HWND>> info = new(Control.GetSafeHandle(ownerWindow));
1733if (win is Control control && control.IsDisposed)
1741ToolInfoWrapper<HandleRef<HWND>> info = new(Control.GetSafeHandle(win));
1749if (win is not Control tool)
1784Control[] controls = [.. _owners.Values];
1793Control? tool = window as Control;
1796ToolInfoWrapper<Control> toolInfo = new(tool);
1831if (window is Control windowAsControl)
1959ToolInfoWrapper<Control> toolInfo = default;
1968private Control? GetCurrentToolWindow()
1971return _owners.TryGetValue(hwnd, out Control? control) ? control : Control.FromHandle(hwnd);
1980if (window is not Control windowAsControl || !_tools.TryGetValue(windowAsControl, out TipInfo? tipInfo))
2005PInvokeCore.GetWindowRect(Control.GetSafeHandle(window), out var r);
2041Control? toolControl = window as Control;
2155if (window is Control windowAsControl && !_tools.TryGetValue(windowAsControl, out tipInfo))
2229if (window is not Control control || !_tools.TryGetValue(control, out TipInfo? tipInfo))
2335font = Control.DefaultFont;
2338Control? control = window as Control ?? Control.FromHandle(window.Handle);