473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Want to use MessageBox without showing the Form

Hello!

I have a small program that just copy a file and make some checks in main
then I just want to inform
the user about something by using a MessageBox.

I tried to use this in the MessageBox that is located in the main function.
This cause compile error because you are not allowed to use this in a static
function.

Now what I want to do is to inform a user by using a MessageBox without
showing the form is that possible?
To show a empty form that the user have to close doesn't seem quite right.

//Tony

Feb 6 '07 #1
4 3651

"TonyJ" <jo*****************@telia.comwrote:
I have a small program that just copy a file and make some checks in main
then I just want to inform
the user about something by using a MessageBox.

I tried to use this in the MessageBox that is located in the main
function.
Why?

What MessageBox do you have in the Main function?
This cause compile error because you are not allowed to use this in a
static
function.

Now what I want to do is to inform a user by using a MessageBox without
showing the form is that possible?
To show a empty form that the user have to close doesn't seem quite right.
As you haven't shown your own attempt to try it, I don't have a clue what
the problem is, but here's a working example, straightforward:
---------------------------------------------------

using System.Windows.Forms;

namespace ConsoleAppWithMessageBox
{
class Program
{
static void Main(string[] args)
{
MessageBox.Show("This works very well");
}
}
}

---------------------------------------------------

/// Bjorn A
Feb 6 '07 #2
Hi Tony,
I'm not sure why you have a problem showing a message box in Main...?

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
MessageBox.Show("hello world");
}
}
}

John

On Feb 6, 6:15 am, "TonyJ" <johansson.anders...@telia.comwrote:
Hello!

I have a small program that just copy a file and make some checks in main
then I just want to inform
the user about something by using a MessageBox.

I tried to use this in the MessageBox that is located in the main function.
This cause compile error because you are not allowed to use this in a static
function.

Now what I want to do is to inform a user by using a MessageBox without
showing the form is that possible?
To show a empty form that the user have to close doesn't seem quite right.

//Tony

Feb 6 '07 #3
Hi,

"TonyJ" <jo*****************@telia.comwrote in message
news:uq**************@TK2MSFTNGP05.phx.gbl...
| Hello!
|
| I have a small program that just copy a file and make some checks in main
| then I just want to inform
| the user about something by using a MessageBox.
|
| I tried to use this in the MessageBox that is located in the main
function.

There is no function inside a function, this is not allowed in C#

Also you can safely use MessageBox.Show directly from the main method
without any problem.
--
Ignacio Machin
machin AT laceupsolutions com
Feb 6 '07 #4
TonyJ,
There shouldn't be a problem to use MessageBox from the Main method. Mabe
the problem is that somewhere in the code you are trying to use some
instance member e.g. a property or field that keeps the text for the
message. Main method is a static one so it has access only to static
members.

Post some sample code that demostrates the problem. I believe your problem
is pretty simple one.
--
Stoitcho Goutsev (100)

"TonyJ" <jo*****************@telia.comwrote in message
news:uq**************@TK2MSFTNGP05.phx.gbl...
Hello!

I have a small program that just copy a file and make some checks in main
then I just want to inform
the user about something by using a MessageBox.

I tried to use this in the MessageBox that is located in the main
function.
This cause compile error because you are not allowed to use this in a
static
function.

Now what I want to do is to inform a user by using a MessageBox without
showing the form is that possible?
To show a empty form that the user have to close doesn't seem quite right.

//Tony

Feb 6 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Matthew Wells | last post by:
I am trying to load a form (load Me) without the form becoming visible. If I try me.hide or me.visible = false, they load the form and the form blinks before becoming invisible. Is there a way to...
4
by: Gerry Viator | last post by:
Hi all, Whats going on. Testing messagebox, text isn't showing up. Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code "
7
by: Bill | last post by:
For some reason, I have an errormessage popup that "blinks", but pops up BEHIND the applications, which is confusing to users. Is there any way to force it to the top?
12
by: Marc Jennings | last post by:
Hi, I have a problem with the message text and button text not showing up in a messagebox. (See attachment) The code I used to call this example was > MessageBox.Show(this,"Hello","nothing...
10
by: Russ | last post by:
I've been trying to figure out how to show a simple messagebox with an OK button in my web client program (C#). I have looked at every reference to JScript and MessageBox that seemed even remotely...
0
by: Deepak C.G via .NET 247 | last post by:
I want to dispose the image object in my child form, unless I won't dispose this object i can't delete the image file in my folder. I get this error in MDIparent form "An unhandled exception...
10
by: pcnerd | last post by:
I've created a demo program that draws random lines on the form. At the end, a messagebox pops up with the words"I'm done!". When I click on "OK", the messagebox disappears, but a white square is...
4
by: Zeba | last post by:
Hi guys, I gave the following code in the page load function of one of my codebehind pages : if (!string.IsNullOrEmpty(keyword)) { System.Windows.Forms.MessageBox.Show("Got your keyword!!");...
1
by: Probi | last post by:
Hello I have a messagebox showing on the click of a button it is a yes/no message box and so far it works in the localhost with MessageBox.Show but when I publish the aspx page and run it on...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.