473,804 Members | 3,674 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3697

"TonyJ" <jo************ *****@telia.com wrote:
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 ConsoleAppWithM essageBox
{
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.Collecti ons.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.ande rs...@telia.com wrote:
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.com wrote in message
news:uq******** ******@TK2MSFTN GP05.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.com wrote in message
news:uq******** ******@TK2MSFTN GP05.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
17076
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 load the form without it becoming visible at all until I say me.visible = true? Thanks. Matthew Wells MWells@NumberCruncher.com
4
1609
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
16978
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
1456
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 shown",MessageBoxButtons.OK,MessageBoxIcon.Information); I had this problem a couple of weeks ago when I was running Windows 2003 Server on my dev machine, and I put it down to an OS / Framework
10
2355
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 like it could help, both in the VS help and in this NG. I found lots of examples of people saying how easy it is and showing examples, and examples in the help. But I have two problems: 1. All the examples show all the code in HTML, usually...
0
1913
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 of type 'System.ArgumentException' occurred in system.windows.forms.dll" "Additional information: Invalid parameter used." Here is my code:-
10
1825
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 left in its place. I can still see the randomly drawn lines on the form, but some are covered up by the white square. How do I prevent the white square from showing after the messagebox closes? Thank you. David
4
6370
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!!"); SearchByKeyword(); }
1
2077
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 the server i get this error "Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a...
0
9704
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9572
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10319
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10070
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7608
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6845
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5508
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2978
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.