Skip to content

Commit d2aed6f

Browse files
committed
* Updates
1 parent ad0da8d commit d2aed6f

3 files changed

Lines changed: 60 additions & 83 deletions

File tree

PR_DESCRIPTION.md

Lines changed: 0 additions & 72 deletions
This file was deleted.

Source/Current/Krypton Components/Krypton.Docking/Control Docking/KryptonSpace.cs

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#region BSD License
1+
#region BSD License
22
/*
33
*
44
* Original BSD 3-Clause License (https://github.com/ComponentFactory/Krypton/blob/master/LICENSE)
@@ -66,6 +66,7 @@ protected class CachedCellState
6666
private readonly EventHandler _visibleUpdate;
6767
private bool _awaitingFocusUpdate;
6868
private bool _awaitingVisibleUpdate;
69+
private bool _pendingVisibleUpdateOnHandle;
6970
private bool _setFocus;
7071
private string _closeTooltip;
7172
private string _pinTooltip;
@@ -243,14 +244,24 @@ public void UpdateVisible(bool focus)
243244
// Cache focus update until invoke occurs
244245
_setFocus = focus;
245246

246-
// No point requesting the update more than once
247-
if (!_awaitingVisibleUpdate && IsHandleCreated)
247+
if (IsHandleCreated)
248248
{
249-
// Async invoke ensures the delegate is called in sync with the message queue, this means that all the
250-
// layout changes for the space control will be finished and so then we can update the visible state of
251-
// the cells to reflect the tab visible changes.
252-
BeginInvoke(_visibleUpdate);
253-
_awaitingVisibleUpdate = true;
249+
// No point requesting the update more than once
250+
if (!_awaitingVisibleUpdate)
251+
{
252+
// Async invoke ensures the delegate is called in sync with the message queue, this means that all the
253+
// layout changes for the space control will be finished and so then we can update the visible state of
254+
// the cells to reflect the tab visible changes.
255+
BeginInvoke(_visibleUpdate);
256+
_awaitingVisibleUpdate = true;
257+
}
258+
}
259+
else
260+
{
261+
// The control has no window handle yet (e.g. form is hidden during config load).
262+
// Defer the visible update until the handle is created so that cell visibility
263+
// and layout are correctly applied once the form becomes visible.
264+
_pendingVisibleUpdateOnHandle = true;
254265
}
255266
}
256267
}
@@ -353,6 +364,23 @@ public override void WritePageElement(XmlWriter xmlWriter, KryptonPage page)
353364
/// </summary>
354365
protected virtual bool ApplyDockingVisibility => true;
355366

367+
/// <summary>
368+
/// Overridden to apply any pending visible update that was deferred because the handle
369+
/// did not exist when <see cref="UpdateVisible(bool)"/> was called (e.g. the form was
370+
/// hidden while a docking configuration was being loaded).
371+
/// </summary>
372+
/// <param name="e">An EventArgs containing the event data.</param>
373+
protected override void OnHandleCreated(EventArgs e)
374+
{
375+
base.OnHandleCreated(e);
376+
377+
if (_pendingVisibleUpdateOnHandle)
378+
{
379+
_pendingVisibleUpdateOnHandle = false;
380+
UpdateVisible(_setFocus);
381+
}
382+
}
383+
356384
/// <summary>
357385
/// Raises the CellGainsFocus event.
358386
/// </summary>

Source/Current/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonComboBox.cs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,7 @@ public ComboBoxButtonSpecCollection(KryptonComboBox owner)
981981
private bool _alwaysActive;
982982
private int _cachedHeight;
983983
private int _hoverIndex;
984+
private bool _dropDownWidthSet;
984985

985986
// #1697 Work-around
986987
// When changing DropDownStyle while the control is disabled the newly selected style was not applied.
@@ -1811,16 +1812,29 @@ public int DropDownHeight
18111812

18121813
/// <summary>
18131814
/// Gets and sets the width, in pixels, of the drop-down box in a KryptonComboBox.
1815+
/// When not explicitly set, the drop-down width follows the control width (matching standard ComboBox behaviour).
18141816
/// </summary>
18151817
[Category(@"Behavior")]
18161818
[Description(@"The width, in pixels, of the drop-down box in a KryptonComboBox.")]
18171819
[EditorBrowsable(EditorBrowsableState.Always)]
18181820
[Browsable(true)]
1819-
[DefaultValue(200)]
18201821
public int DropDownWidth
18211822
{
1822-
get => _comboBox.DropDownWidth;
1823-
set => _comboBox.DropDownWidth = value;
1823+
get => _dropDownWidthSet ? _comboBox.DropDownWidth : Width;
1824+
set
1825+
{
1826+
_dropDownWidthSet = true;
1827+
_comboBox.DropDownWidth = value;
1828+
}
1829+
}
1830+
1831+
private bool ShouldSerializeDropDownWidth() => _dropDownWidthSet;
1832+
1833+
/// <summary>Resets the DropDownWidth to its default (follows the control width).</summary>
1834+
public void ResetDropDownWidth()
1835+
{
1836+
_dropDownWidthSet = false;
1837+
_comboBox.DropDownWidth = Width;
18241838
}
18251839

18261840
/// <summary>
@@ -2688,6 +2702,13 @@ protected override void OnResize(EventArgs e)
26882702
// Let base class raise events
26892703
base.OnResize(e);
26902704

2705+
// Keep the inner combo's DropDownWidth in sync when it hasn't been explicitly set,
2706+
// mirroring the standard ComboBox behaviour where the drop-down tracks the control width.
2707+
if (!_dropDownWidthSet)
2708+
{
2709+
_comboBox.DropDownWidth = Width;
2710+
}
2711+
26912712
// We must have a layout calculation
26922713
ForceControlLayout();
26932714
}

0 commit comments

Comments
 (0)