Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
1.00/5 (1 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

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();
        }
    }
}
 
Share this answer
 
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900