Skip to content

Commit c590898

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 c590898

File tree

3 files changed

+49
-30
lines changed

3 files changed

+49
-30
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: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2566,44 +2566,59 @@ 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-
}
2571+
get => _flags.HasFlag(Flags.EditMouseDown);
2572+
private set => SetFlag(Flags.EditMouseDown, value);
2573+
}
25812574

2582-
if (_rowSelectTime == 0)
2575+
private void OnEditMouseDown(object? sender, MouseEventArgs e)
2576+
{
2577+
try
25832578
{
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
2579+
EditMouseDown = true;
25912580

2592-
if (delta < SystemInformation.DoubleClickTime)
2593-
{
2594-
Point screenPoint = EditTextBox.PointToScreen(e.Location);
2581+
if (!FocusInside)
2582+
{
2583+
SelectGridEntry(_selectedGridEntry, pageIn: false);
2584+
}
25952585

2596-
if (Math.Abs(screenPoint.X - _rowSelectPos.X) < SystemInformation.DoubleClickSize.Width &&
2597-
Math.Abs(screenPoint.Y - _rowSelectPos.Y) < SystemInformation.DoubleClickSize.Height)
2586+
if (e.Clicks % 2 == 0)
25982587
{
25992588
DoubleClickRow(_selectedRow, toggleExpand: false, RowValue);
2600-
PInvokeCore.SendMessage(EditTextBox, PInvokeCore.WM_LBUTTONUP, (WPARAM)0, (LPARAM)e.Location);
26012589
EditTextBox.SelectAll();
26022590
}
26032591

2604-
_rowSelectPos = Point.Empty;
2592+
if (_rowSelectTime == 0)
2593+
{
2594+
return;
2595+
}
26052596

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

@@ -3992,7 +4007,7 @@ private void Refresh(bool fullRefresh, int startRow, int endRow)
39924007
startRow = 0;
39934008
}
39944009

3995-
if (OwnerGrid.HavePropertyEntriesChanged())
4010+
if (fullRefresh || OwnerGrid.HavePropertyEntriesChanged())
39964011
{
39974012
if (HasEntries && !InPropertySet && !CommitEditTextBox())
39984013
{

0 commit comments

Comments
 (0)