Skip to content

Commit 0e9222e

Browse files
committed
Update the logic about the attribute [RefreshProperties(RefreshProperties.All)] on PropertyGridView.cs
1 parent 89e6bb9 commit 0e9222e

File tree

2 files changed

+25
-16
lines changed
  • src/System.Windows.Forms

2 files changed

+25
-16
lines changed

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4018,7 +4018,10 @@ private void Refresh(bool fullRefresh, int startRow, int endRow)
40184018
if (oldLength > 0 && !_flags.HasFlag(Flags.NoDefault))
40194019
{
40204020
_positionData = CaptureGridPositionData();
4021-
CommonEditorHide(true);
4021+
if (!fullRefresh)
4022+
{
4023+
CommonEditorHide(true);
4024+
}
40224025
}
40234026

40244027
UpdateHelpAttributes(_selectedGridEntry, newEntry: null);
@@ -4299,17 +4302,10 @@ private void SelectRow(int row)
42994302
return;
43004303
}
43014304

4302-
bool newRow = false;
43034305
int oldSelectedRow = _selectedRow;
4304-
if (_selectedRow != row || !gridEntry.Equals(_selectedGridEntry))
4306+
if (_selectedRow != row || (_selectedGridEntry is not null && !gridEntry.Equals(_selectedGridEntry)))
43054307
{
43064308
CommonEditorHide();
4307-
newRow = true;
4308-
}
4309-
4310-
if (!newRow)
4311-
{
4312-
CloseDropDown();
43134309
}
43144310

43154311
Rectangle rect = GetRectangle(row, RowValue);
@@ -4400,7 +4396,7 @@ private void SelectRow(int row)
44004396
_selectedGridEntry.HasFocus = FocusInside;
44014397
}
44024398

4403-
if (!_flags.HasFlag(Flags.IsNewSelection))
4399+
if (!_flags.HasFlag(Flags.IsNewSelection) && !_flags.HasFlag(Flags.InPropertySet))
44044400
{
44054401
Focus();
44064402
}

src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.cs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,22 +124,35 @@ private void CreateDesignSurface(int n)
124124
// - create some Controls at DesignTime
125125
TextBox t1 = surface.CreateControl<TextBox>(new Size(200, 23), new Point(172, 12));
126126
Button b1 = surface.CreateControl<Button>(new Size(200, 40), new Point(172, 63));
127-
CustomButton b2 = surface.CreateControl<CustomButton>(new Size(200, 40), new Point(100, 200));
127+
CustomButton b2 = surface.CreateControl<CustomButton>(new Size(200, 40), new Point(172, 200));
128128
b1.Text = "I'm the first Button";
129129
b2.Text = "I'm the second Button";
130130
b1.BackColor = Color.LightGray;
131131
b2.BackColor = Color.LightGreen;
132132

133-
RadioButton rb1 = surface.CreateControl<RadioButton>(new Size(120, 22), new Point(12, 21));
133+
RadioButton rb1 = surface.CreateControl<RadioButton>(new Size(120, 22), new Point(12, 10));
134134
rb1.Text = "Check me!";
135-
RadioButton rb2 = surface.CreateControl<RadioButton>(new Size(120, 22), new Point(12, 50));
135+
RadioButton rb2 = surface.CreateControl<RadioButton>(new Size(120, 22), new Point(12, 35));
136136
rb2.Text = "No, check me!";
137137
rb2.Checked = true;
138138

139-
Panel pnl = surface.CreateControl<Panel>(new Size(130, 100), new Point(12, 21));
139+
CheckBox checkbox1 = surface.CreateControl<CheckBox>(new Size(120, 22), new Point(12, 60));
140+
checkbox1.Text = "I'm Unchecked!";
141+
CheckBox checkbox2 = surface.CreateControl<CheckBox>(new Size(120, 22), new Point(12, 85));
142+
checkbox2.Text = "I'm Indeterminate!";
143+
checkbox2.AutoSize = true;
144+
checkbox2.CheckState = CheckState.Indeterminate;
145+
CheckBox checkbox3 = surface.CreateControl<CheckBox>(new Size(120, 22), new Point(12, 110));
146+
checkbox3.Text = "I'm Checked!";
147+
checkbox3.CheckState = CheckState.Checked;
148+
149+
Panel pnl = surface.CreateControl<Panel>(new Size(140, 140), new Point(12, 12));
140150
pnl.BackColor = Color.Aquamarine;
141151
rb1.Parent = pnl;
142152
rb2.Parent = pnl;
153+
checkbox1.Parent = pnl;
154+
checkbox2.Parent = pnl;
155+
checkbox3.Parent = pnl;
143156

144157
Label l1 = surface.CreateControl<Label>(new Size(100, 25), new Point(12, 12));
145158
Label l2 = surface.CreateControl<Label>(new Size(120, 25), new Point(12, 12));
@@ -154,7 +167,7 @@ private void CreateDesignSurface(int n)
154167
l1.Parent = sct.Panel1;
155168
l2.Parent = sct.Panel2;
156169

157-
PictureBox pb1 = surface.CreateControl<PictureBox>(new Size(64, 64), new Point(24, 166));
170+
PictureBox pb1 = surface.CreateControl<PictureBox>(new Size(64, 64), new Point(12, 176));
158171
pb1.Image = new Icon("painter.ico").ToBitmap();
159172

160173
ContextMenuStrip cm1 = surface.CreateComponent<ContextMenuStrip>();
@@ -333,7 +346,7 @@ private void CreateDesignSurface(int n)
333346
splitter.BackColor = Color.Green;
334347
splitter.Dock = DockStyle.Bottom;
335348

336-
Panel panel = surface.CreateControl<Panel>(new(0, tabPage6.Height/2), new(0, 0));
349+
Panel panel = surface.CreateControl<Panel>(new(0, tabPage6.Height / 2), new(0, 0));
337350
panel.Dock = DockStyle.Bottom;
338351
NumericUpDown numericUpDown = surface.CreateControl<NumericUpDown>(new(50, 10), new(10, 10));
339352
panel.Controls.Add(numericUpDown);

0 commit comments

Comments
 (0)