83 lines
2.1 KiB
C#
83 lines
2.1 KiB
C#
namespace StockHistory.Forms;
|
|
|
|
public class NoWrapMessageBox : Form
|
|
{
|
|
private Label line1;
|
|
private Label line2;
|
|
private Label line3;
|
|
private Button yesButton;
|
|
private Button noButton;
|
|
|
|
public NoWrapMessageBox(string row1, string row2)
|
|
{
|
|
Text = "Bekräfta";
|
|
StartPosition = FormStartPosition.CenterScreen;
|
|
FormBorderStyle = FormBorderStyle.FixedDialog;
|
|
MaximizeBox = false;
|
|
MinimizeBox = false;
|
|
ShowInTaskbar = false;
|
|
Size = new Size(1000, 180);
|
|
|
|
TopMost = true; // ← gör att dialogen hamnar överst
|
|
|
|
line1 = new Label()
|
|
{
|
|
Text = row1,
|
|
AutoSize = true,
|
|
Location = new Point(20, 20),
|
|
Font = new Font("Consolas", 9),
|
|
MaximumSize = Size.Empty // ingen wrapping
|
|
};
|
|
|
|
line2 = new Label()
|
|
{
|
|
Text = row2,
|
|
AutoSize = true,
|
|
Location = new Point(20, 50),
|
|
Font = new Font("Consolas", 9),
|
|
MaximumSize = Size.Empty
|
|
};
|
|
|
|
line3 = new Label()
|
|
{
|
|
Text = "Kan posten läggas till ?",
|
|
AutoSize = true,
|
|
Location = new Point(20, 80),
|
|
Font = new Font("Consolas", 10),
|
|
MaximumSize = Size.Empty
|
|
};
|
|
|
|
yesButton = new Button()
|
|
{
|
|
Text = "Yes",
|
|
DialogResult = DialogResult.Yes,
|
|
Location = new Point(350, 100),
|
|
Size = new Size(100, 30)
|
|
};
|
|
|
|
noButton = new Button()
|
|
{
|
|
Text = "No",
|
|
DialogResult = DialogResult.No,
|
|
Location = new Point(460, 100),
|
|
Size = new Size(100, 30)
|
|
};
|
|
|
|
Controls.Add(line1);
|
|
Controls.Add(line2);
|
|
Controls.Add(line3);
|
|
Controls.Add(yesButton);
|
|
Controls.Add(noButton);
|
|
|
|
AcceptButton = yesButton;
|
|
CancelButton = noButton;
|
|
}
|
|
|
|
public static DialogResult Show(string row1, string row2)
|
|
{
|
|
using (var dlg = new NoWrapMessageBox(row1, row2))
|
|
{
|
|
return dlg.ShowDialog();
|
|
}
|
|
}
|
|
} |