atomicgs12
asked on
C# how to display message box without form
I have a C# console application written for windows mobile. Is there a way to display a message box/dialog to the user if I don't have a form class in my application? Short example would be nice.
http://www.flounder.com/consoledialogs.htm
Easily:
Just call:
System.Forms.MessageBox.Sh owDialog(" This is your text");
Just call:
System.Forms.MessageBox.Sh
Sorry:
System.Windows.Forms.Messa geBox.Show Dialog("Th is is your text");
System.Windows.Forms.Messa
Forgot again - you also need to add a reference to your project: to System.Windows.Forms.
One more my mistake: Show, not ShowDialog. I tested the code below :)
static void Main(string[] args)
{
System.Windows.Forms.MessageBox.Show("Hello");
}
ASKER
jimbel -
When I cut and paste your example into my code I am getting this error:
"Error 1 The type or namespace name 'Windows' does not exist in the namespace 'System' (are you missing an assembly reference?)"
am I missing something in my directives? Is there something in my AssemblyInfo.cs I should be including?
When I cut and paste your example into my code I am getting this error:
"Error 1 The type or namespace name 'Windows' does not exist in the namespace 'System' (are you missing an assembly reference?)"
am I missing something in my directives? Is there something in my AssemblyInfo.cs I should be including?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If we want to pop up messagebox in console app, we should add the reference
to System.Windows.Forms.dll. You could refer to the following code and I
hope it's useful for you,
using System;
namespace ConsoleApplication1
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
System.Windows.Forms.Messa geBox.Show ("Hello World");
}
}
}
to System.Windows.Forms.dll. You could refer to the following code and I
hope it's useful for you,
using System;
namespace ConsoleApplication1
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
System.Windows.Forms.Messa
}
}
}
ramkisan, is your answer somehow different from mine?!
ASKER
Every one gave great answers but I am awarding the points to first correct answer. Thank You all
anarki_jimbel,
Sorry if you think I have reapeted ur answer., But I havn't read your all the comments before answering the question.
Regards,
Ramkisan
Sorry if you think I have reapeted ur answer., But I havn't read your all the comments before answering the question.
Regards,
Ramkisan
No response from Author yet.
Hi,
Comment ID:33555951 should be also accepted as solution to the Author's question.
Regards,
VSS
Comment ID:33555951 should be also accepted as solution to the Author's question.
Regards,
VSS