Click here to Skip to main content
13,901,218 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
I am trying to know how to use a MessageBox that display pop-up windows that every time the button on each pop-up window is clicked, it displays a count from 1 to 10 in numeric order. However I am unable to find the results based on my research and would like to try this set of codes which doesn't help much at all with this situation.

What I have tried:

namespace print_number_1_to_10
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.BufferHeight = 10;

            for (int i = 1; i <= 10; i = i + 1)
            {
                Console.WriteLine(i);
            }


            Console.ReadLine();
        }
    }
}
Posted
Updated 26-Aug-18 19:12pm
Comments
Richard MacCutchan 27-Aug-18 4:15am
   
That is a Console based program which does not have a MessageBox feature. You need to create a Windows Forms application.

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace sample
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.BufferHeight = 10;

            for (int i = 1; i <= 10; i = i + 1)
            {
                MessageBox.Show(i.ToString());
            }
            Console.ReadLine();
        }
    }
}
   
Comments
Member 13962419 27-Aug-18 2:13am
   
Severity Code Description:
'Form1.Dispose(bool)': no suitable method found to override
'object' does not contain a definition for 'Dispose'
'Form1' does not contain a definition for 'AutoScaleMode' and no extension method 'AutoScaleMode' accepting a first argument of type 'Form1' could be found (are you missing a using directive or an assembly reference?)
'Form1' does not contain a definition for 'Text' and no extension method 'Text' accepting a first argument of type 'Form1' could be found (are you missing a using directive or an assembly reference?)
Program has more than one entry point defined. Compile with /main to specify the type that contains the entry point.
'sample' is a namespace but is used like a type
Er. Puneet Goel 27-Aug-18 2:24am
   
use only this section, static void Main(string[] args)
{
//Console.BufferHeight = 10;

for (int i = 1; i <= 10; i = i + 1)
{
MessageBox.Show(i.ToString());
}
Console.ReadLine();
}

and include 'using System.Windows.Forms;' namespace.
This is ver basic

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web01 | 2.8.190306.1 | Last Updated 27 Aug 2018
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100