Why?
I built a simple custom MessageBox as as a Dialog in C#. When I show the message boxvia Show(), the message text is not highlighted. When I show this messagebox vi ShowDialog(), the text is highlighted.
I don’t want my text to be highlighted. Any thoughts or ideas?
public partial class MyMessageBox : Form
{
private String mCaption;
private String mMessage;
public MyMessageBox( Form anOwner, String aCaption, String aMessage )
{
InitializeComponent();
mCaption = aCaption;
Owner = anOwner;
mMessage = aMessage;
}
private void btnCancelRequest_Click( object sender, EventArgs e )
{
( (AddressForm)Owner ).RequestCancelled();
}
private void btnOk_Click( object sender, EventArgs e )
{
CloseDialog();
}
public void CloseDialog()
{
Close();
}
// Called from the Address Form
public void HideCancelRequestButton()
{
btnCancelRequest.Visible = false;
}
private void MyMessageBox_Activated( object sender, EventArgs e )
{
Text = mCaption;
txtMessage.Text = mMessage;
}
}
While I don’t see why the text would be highlighted, you could avoid this by explicitly specifying the textbox selection length:
though as Jeremy commented, this may be a better use of a label unless you’re actually expecting user input.