Skip to content

Commit

Permalink
show an example of removing a column entirely
Browse files Browse the repository at this point in the history
  • Loading branch information
Edward Miller committed Dec 27, 2023
1 parent 13e0429 commit e9ed6de
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 1 addition & 2 deletions Maui.DataGrid.Sample/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
<Label Text="Header Borders Visible?" TextColor="White" Margin="0,0,5,0" VerticalOptions="Center" />
</HorizontalStackLayout>
<HorizontalStackLayout HeightRequest="50" Margin="0,0,15,0">
<CheckBox IsChecked="{Binding TeamColumnVisible}" />
<Label Text="Team Column" TextColor="White" Margin="0,0,5,0" VerticalOptions="Center" />
<Button Text="Remove Teams" Clicked="OnRemoveTeamColumn" />
</HorizontalStackLayout>
<HorizontalStackLayout HeightRequest="50" Margin="0,0,15,0">
<CheckBox IsChecked="{Binding WonColumnVisible}" />
Expand Down
10 changes: 10 additions & 0 deletions Maui.DataGrid.Sample/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,14 @@ private void OnAddColumn(object sender, EventArgs e)
{
_dataGrid1.Columns.Add(new DataGridColumn() { Title = "Test", Width = new(100) });
}

private void OnRemoveTeamColumn(object sender, EventArgs e)
{
var teamColumn = _dataGrid1.Columns.FirstOrDefault(c => c.Title == "Team");

if (teamColumn != null)
{
_ = _dataGrid1.Columns.Remove(teamColumn);
}
}
}

0 comments on commit e9ed6de

Please sign in to comment.