Results 1 to 6 of 6

Thread: [RESOLVED] is there a Ok/ Cancel message box equivalent?

  1. #1

    Thread Starter
    Hyperactive Member drattansingh's Avatar
    Join Date
    Sep 2005
    Posts
    395

    Resolved [RESOLVED] is there a Ok/ Cancel message box equivalent?

    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

  2. #2

    Thread Starter
    Hyperactive Member drattansingh's Avatar
    Join Date
    Sep 2005
    Posts
    395

    Re: is there a Ok/ Cancel message box equivalent?

    Something like the JOptionPane in Java.

  3. #3
    Fanatic Member BillBoeBaggins's Avatar
    Join Date
    Jan 2003
    Location
    in your database, dropping your tables.
    Posts
    628

    Re: is there a Ok/ Cancel message box equivalent?

    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

  4. #4
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: is there a Ok/ Cancel message box equivalent?

    The MessageBox class can display text and you can add buttons for yes or No. No text input though
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  5. #5
    Banned
    Join Date
    Nov 2005
    Posts
    2,367

    Re: is there a Ok/ Cancel message box equivalent?

    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.

    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;
    			}
    
    		}
    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.

  6. #6

    Thread Starter
    Hyperactive Member drattansingh's Avatar
    Join Date
    Sep 2005
    Posts
    395

    Re: is there a Ok/ Cancel message box equivalent?

    Thanks guys! it worked.

    Jennifer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width