kvnsdr
asked on
Custom Width Message Box per Label Length?
I have two problems:
1. My text does not show on my message box, I found the Thread(sleep) is a problem.....
2. I would like to base the winform (custom message box) on the varrying label length...
Leave it to microsoft to NOT allow for a more flexable MessageBox.Show.
As if thier thousands of programmers have never needed to auto-close one.
Anyway, here's what I have so far:
[Messages form]
private void Messages_Load(object sender, EventArgs e)
{
this.Width = lblMessage.Text.Length; // always too narrow, cuts-off half of label.
}
[Form1] calling Messages form to open....
Messages msg = new Messages();
msg.lblMessage.Text = "Thank You For Choosing Us";
msg.Show();
Thread.Sleep(3000);
msg.Close();
1. My text does not show on my message box, I found the Thread(sleep) is a problem.....
2. I would like to base the winform (custom message box) on the varrying label length...
Leave it to microsoft to NOT allow for a more flexable MessageBox.Show.
As if thier thousands of programmers have never needed to auto-close one.
Anyway, here's what I have so far:
[Messages form]
private void Messages_Load(object sender, EventArgs e)
{
this.Width = lblMessage.Text.Length; // always too narrow, cuts-off half of label.
}
[Form1] calling Messages form to open....
Messages msg = new Messages();
msg.lblMessage.Text = "Thank You For Choosing Us";
msg.Show();
Thread.Sleep(3000);
msg.Close();
ASKER
That sounds like a great idea.
Any idea why the message form doesn't expand to the correct width?
Any idea why the message form doesn't expand to the correct width?
yes, do you want your message shown in one line or in multiline?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
WshShell.Popup:
http://www.ss64.com/wsh/popup.html
Notice the 'nSecondsToWait'.
1) Add a COM reference to 'Windows Script Host Object Model'
2) Instantiate a WshShell object
3) Call the Popup method
Bob
http://www.ss64.com/wsh/popup.html
Notice the 'nSecondsToWait'.
1) Add a COM reference to 'Windows Script Host Object Model'
2) Instantiate a WshShell object
3) Call the Popup method
Bob
if its count down from 3 seconds, close your Messages form.