Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Further fixes removing controls from TableLayout #2592

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Eto.WinForms/Forms/TableLayoutHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public void Remove(Control child)
if (childControl.Parent == Control)
{
var pos = Control.GetCellPosition(childControl);
if (views != null)
if (views != null && ReferenceEquals(views[pos.Column, pos.Row], child))
views[pos.Column, pos.Row] = null;
childControl.Parent = null;
SetEmptyCell(pos.Column, pos.Row);
Expand Down
12 changes: 11 additions & 1 deletion src/Eto.Wpf/Forms/TableLayoutHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -423,10 +423,20 @@ public void Remove(Control child)

public override void Remove(sw.FrameworkElement child)
{
// ensure this is actually a child of this table
if (child.Parent != Control)
return;

// row and column could be for a different table
var x = swc.Grid.GetColumn(child);
var y = swc.Grid.GetRow(child);
Control.Children.Remove(child);
controls[x, y] = null;
if (controls != null
&& x >= 0 && x < controls.GetLength(0)
&& y >= 0 && y < controls.GetLength(1)
&& ReferenceEquals(controls[x,y]?.GetContainerControl(), child)
)
controls[x, y] = null;
OnChildPreferredSizeUpdated();
}
}
Expand Down