Add table example check to prevent crashes (#2691)

Co-authored-by: Tig <tig@users.noreply.github.com>
This commit is contained in:
Maciej
2023-07-06 00:52:13 +02:00
committed by GitHub
parent 409de821c1
commit 7936dd1e85

View File

@@ -250,6 +250,11 @@ namespace UICatalog.Scenarios {
private void SetMinAcceptableWidthToOne ()
{
var columns = tableView?.Table?.Columns;
if (columns is null) {
MessageBox.ErrorQuery ("No Table", "No table is currently loaded", "Ok");
return;
}
foreach (DataColumn c in tableView.Table.Columns)
{
var style = tableView.Style.GetOrCreateColumnStyle (c);
@@ -276,6 +281,10 @@ namespace UICatalog.Scenarios {
private void RunColumnWidthDialog (DataColumn col, string prompt, Action<ColumnStyle,int> setter,Func<ColumnStyle,int> getter)
{
if (col is null) {
MessageBox.ErrorQuery ("No Table", "No table is currently loaded", "Ok");
return;
}
var accepted = false;
var ok = new Button ("Ok", is_default: true);
ok.Clicked += () => { accepted = true; Application.RequestStop (); };