I'm having troubles rendering my custom non blocking 'MessageBox' like form. So I have made my Alert form:
public partial class Alert : Form
{
public Alert(string title, string text)
{
InitializeComponent();
this.Text = title;
labelText.Text = text;
}
private void buttonOk_Click(object sender, System.EventArgs e)
{
Close();
}
}
and looks like this in designer:
But when I try to open this Alert form within my main form like this:
var alert = new Alert("Test", "Hello, this is test.");
alert.Show();
Then my Alert form renders like this:
Where is my button and label?
//EDIT
alert.ShowDialog();
renders the form as intended
The method I'm using this form in:
private void buttonTestConnection_Click(object sender, EventArgs e)
{
var f = new Alert("Test", "Hello, this is test");
f.Show();
Thread.Sleep(2000);
var result = TestSqlConnection(); // This may that a while
if (result)
{
f.Close();
MessageBox.Show("Test", "Test successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
f.Close();
MessageBox.Show("Test", "Connection failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

