add controls on load

- hopefully fixes initial focus being on confirm button
This commit is contained in:
Pilzinsel64
2025-01-14 08:38:40 +01:00
parent cfce855c2c
commit 91eeab7aeb
2 changed files with 33 additions and 6 deletions

View File

@@ -7,6 +7,8 @@ namespace Pilz.UI.Telerik.Dialogs;
public partial class RadFlyoutBase : UserControl
{
private bool addedControlsToUi;
private RadButton radButton_Cancel;
private RadButton radButton_Confirm;
private TableLayoutPanel tableLayoutPanel_ActionPanel;
@@ -152,6 +154,7 @@ public partial class RadFlyoutBase : UserControl
ColumnCount = 3,
RowCount = 1,
};
tableLayoutPanel_ActionPanel.SuspendLayout();
tableLayoutPanel_ActionPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
tableLayoutPanel_ActionPanel.ColumnStyles.Add(new ColumnStyle());
tableLayoutPanel_ActionPanel.ColumnStyles.Add(new ColumnStyle());
@@ -169,6 +172,7 @@ public partial class RadFlyoutBase : UserControl
ColumnCount = 1,
RowCount = 1
};
tableLayoutPanel_TitlePanel.SuspendLayout();
tableLayoutPanel_TitlePanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
tableLayoutPanel_TitlePanel.Controls.Add(radLabel_Title, 0, 0);
tableLayoutPanel_TitlePanel.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
@@ -177,9 +181,26 @@ public partial class RadFlyoutBase : UserControl
// RadFlyoutBase
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(tableLayoutPanel_TitlePanel);
Controls.Add(tableLayoutPanel_ActionPanel);
Size = new Size(300, 150);
tableLayoutPanel_TitlePanel.ResumeLayout(false);
tableLayoutPanel_ActionPanel.ResumeLayout(false);
}
protected override void OnLoad(EventArgs e)
{
if (!addedControlsToUi)
{
SuspendLayout();
Controls.Add(tableLayoutPanel_ActionPanel);
tableLayoutPanel_ActionPanel.BringToFront();
Controls.Add(tableLayoutPanel_TitlePanel);
tableLayoutPanel_TitlePanel.BringToFront();
ResumeLayout(false);
PerformLayout();
addedControlsToUi = true;
}
base.OnLoad(e);
}
protected virtual void FlyoutDialogBase_ParentChanged(object? sender, EventArgs e)