Skip to content

Commit 50fac01

Browse files
committed
fix #13071 Changing properties with RefreshProperties.All does not requery the property list in the PropertyGrid in .net 9 (worked in .net 8) : revert PR#12431 , use another approach.
1 parent 88c3a11 commit 50fac01

File tree

3 files changed

+48
-31
lines changed

3 files changed

+48
-31
lines changed

src/System.Windows.Forms/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/GridEntry.GridEntryAccessibleObject.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,10 @@ internal override void SetFocus()
410410

411411
base.SetFocus();
412412

413-
RaiseAutomationEvent(UIA_EVENT_ID.UIA_AutomationFocusChangedEventId);
413+
if (!PropertyGridView.InPropertySet && !PropertyGridView.EditMouseDown)
414+
{
415+
RaiseAutomationEvent(UIA_EVENT_ID.UIA_AutomationFocusChangedEventId);
416+
}
414417
}
415418
}
416419
}

src/System.Windows.Forms/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.Flags.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ private enum Flags : ushort
2222
/// </summary>
2323
ButtonLaunchedEditor = 0x0100,
2424
NoDefault = 0x0200,
25-
ResizableDropDown = 0x0400
25+
ResizableDropDown = 0x0400,
26+
EditMouseDown = 0x0800
2627
}
2728
}

src/System.Windows.Forms/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.cs

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2566,44 +2566,57 @@ private void OnEditLostFocus(object? sender, EventArgs e)
25662566
InvokeLostFocus(this, EventArgs.Empty);
25672567
}
25682568

2569-
private void OnEditMouseDown(object? sender, MouseEventArgs e)
2569+
internal bool EditMouseDown
25702570
{
2571-
if (!FocusInside)
2572-
{
2573-
SelectGridEntry(_selectedGridEntry, pageIn: false);
2574-
}
2575-
2576-
if (e.Clicks % 2 == 0)
2577-
{
2578-
DoubleClickRow(_selectedRow, toggleExpand: false, RowValue);
2579-
EditTextBox.SelectAll();
2580-
}
2581-
2582-
if (_rowSelectTime == 0)
2583-
{
2584-
return;
2585-
}
2586-
2587-
// Check if the click happened within the double click time since the row was selected.
2588-
// This allows the edits to be selected with two clicks instead of 3 (select row, double click).
2589-
long timeStamp = DateTime.Now.Ticks;
2590-
int delta = (int)((timeStamp - _rowSelectTime) / 10000); // make it milliseconds
2571+
get => _flags.HasFlag(Flags.EditMouseDown);
2572+
private set => SetFlag(Flags.EditMouseDown, value);
2573+
}
25912574

2592-
if (delta < SystemInformation.DoubleClickTime)
2575+
private void OnEditMouseDown(object? sender, MouseEventArgs e)
2576+
{
2577+
try
25932578
{
2594-
Point screenPoint = EditTextBox.PointToScreen(e.Location);
2579+
if (!FocusInside)
2580+
{
2581+
SelectGridEntry(_selectedGridEntry, pageIn: false);
2582+
}
25952583

2596-
if (Math.Abs(screenPoint.X - _rowSelectPos.X) < SystemInformation.DoubleClickSize.Width &&
2597-
Math.Abs(screenPoint.Y - _rowSelectPos.Y) < SystemInformation.DoubleClickSize.Height)
2584+
if (e.Clicks % 2 == 0)
25982585
{
25992586
DoubleClickRow(_selectedRow, toggleExpand: false, RowValue);
2600-
PInvokeCore.SendMessage(EditTextBox, PInvokeCore.WM_LBUTTONUP, (WPARAM)0, (LPARAM)e.Location);
26012587
EditTextBox.SelectAll();
26022588
}
26032589

2604-
_rowSelectPos = Point.Empty;
2590+
if (_rowSelectTime == 0)
2591+
{
2592+
return;
2593+
}
26052594

2606-
_rowSelectTime = 0;
2595+
// Check if the click happened within the double click time since the row was selected.
2596+
// This allows the edits to be selected with two clicks instead of 3 (select row, double click).
2597+
long timeStamp = DateTime.Now.Ticks;
2598+
int delta = (int)((timeStamp - _rowSelectTime) / 10000); // make it milliseconds
2599+
2600+
if (delta < SystemInformation.DoubleClickTime)
2601+
{
2602+
Point screenPoint = EditTextBox.PointToScreen(e.Location);
2603+
2604+
if (Math.Abs(screenPoint.X - _rowSelectPos.X) < SystemInformation.DoubleClickSize.Width &&
2605+
Math.Abs(screenPoint.Y - _rowSelectPos.Y) < SystemInformation.DoubleClickSize.Height)
2606+
{
2607+
DoubleClickRow(_selectedRow, toggleExpand: false, RowValue);
2608+
PInvokeCore.SendMessage(EditTextBox, PInvokeCore.WM_LBUTTONUP, (WPARAM)0, (LPARAM)e.Location);
2609+
EditTextBox.SelectAll();
2610+
}
2611+
2612+
_rowSelectPos = Point.Empty;
2613+
2614+
_rowSelectTime = 0;
2615+
}
2616+
}
2617+
finally
2618+
{
2619+
EditMouseDown = false;
26072620
}
26082621
}
26092622

@@ -3992,7 +4005,7 @@ private void Refresh(bool fullRefresh, int startRow, int endRow)
39924005
startRow = 0;
39934006
}
39944007

3995-
if (OwnerGrid.HavePropertyEntriesChanged())
4008+
if (fullRefresh || OwnerGrid.HavePropertyEntriesChanged())
39964009
{
39974010
if (HasEntries && !InPropertySet && !CommitEditTextBox())
39984011
{

0 commit comments

Comments
 (0)