Hi. Is there anything in c# where you could popup and ask the user to enter probably some simple text or a yes / cancel two button option like in Java?
Jennifer
Printable View
Hi. Is there anything in c# where you could popup and ask the user to enter probably some simple text or a yes / cancel two button option like in Java?
Jennifer
Something like the JOptionPane in Java.
If you were programming in VB you just would of used InputBox(), but this has been done away with and you apparently come from a Java background.
So your options are to reference the old InputBox() through the old VB namespace, or to just create your own. Or you can visit the first link where I believe it is already made.
http://www.devhood.com/Tools/tool_de...px?tool_id=295
http://faculty.juniata.edu/rhodes/smui/csmsgbox.htm
The MessageBox class can display text and you can add buttons for yes or No. No text input though
If you were programming in "legacy" VB, you would use the InputBox()
(You probably meant it that way, I just wanted to clarify the difference :))
The yes/no messagebox option is avaliable in the Framework.
As far as creating your own (like the previous posts), it is your best way to go. Remember to use .ShowDialog() instead of .Show. It will display modally that way.Code:private void Form1_Load(object sender, System.EventArgs e)
{
System.Windows.Forms.DialogResult Response;
Response = System.Windows.Forms.MessageBox.Show("Contents", "Caption", System.Windows.Forms.MessageBoxButtons.YesNo);
switch(Response)
{
case System.Windows.Forms.DialogResult.Yes:
System.Windows.Forms.MessageBox.Show("YES");
break;
case System.Windows.Forms.DialogResult.No:
System.Windows.Forms.MessageBox.Show("NO");
break;
default:
break;
}
}
Thanks guys! it worked.
Jennifer