473,320 Members | 2,041 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,320 software developers and data experts.

Inherit from messagebox in c#

I am trying to inherit from MessageBox and i get error in
compilation time.

The code is:
public class MyMessageBox : MessageBox
{
public static DialogResult Show(int errorCode)
{
return DialogResult.OK;
}
}

The error is:
System.Windows.Forms.MessageBox.MessageBox() is
inaccessible due to its protection level

I guess it because the constructor of MessageBox is privte.
My question is, is there anyway to inherit from messagebox?

Thanks,
Adam
Jul 19 '05 #1
2 9560
Adam <ad***@elbit.co.il> wrote:
I am trying to inherit from MessageBox and i get error in
compilation time.

The code is:
public class MyMessageBox : MessageBox
{
public static DialogResult Show(int errorCode)
{
return DialogResult.OK;
}
}

The error is:
System.Windows.Forms.MessageBox.MessageBox() is
inaccessible due to its protection level

I guess it because the constructor of MessageBox is privte.
My question is, is there anyway to inherit from messagebox?


No. Unless a class has at least one protected or public (or internal if
you're in the same assembly) constructor, you can't inherit from it (in
C# at least).

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Jul 19 '05 #2
Adam wrote:
|| I am trying to inherit from MessageBox and i get error in
|| compilation time.
||
|| The code is:
|| public class MyMessageBox : MessageBox
|| {
|| public static DialogResult Show(int errorCode)
|| {
|| return DialogResult.OK;
|| }
|| }
||
|| The error is:
|| System.Windows.Forms.MessageBox.MessageBox() is
|| inaccessible due to its protection level
||
|| I guess it because the constructor of MessageBox is privte.
|| My question is, is there anyway to inherit from messagebox?
||
|| Thanks,
|| Adam

No, the class has only a private constructor, so you can't derive from nor create an instance of the class.

Willy.
Jul 19 '05 #3

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

Similar topics

7
by: Fabian Neumann | last post by:
Hi! I got a problem with font-family inheritance. Let's say I have CSS definitions like: p { font:normal 10pt Verdana; } strong { font:normal 14pt inherit;
11
by: Rich Tasker | last post by:
I have a strange situation. A simple call to MessageBox.Show("XXX", "YYY") does not display the message in the messagebox with a visible font. Based on the content of the messagebox, the box...
2
by: Dennis C. Drumm | last post by:
This is a restatement of an earlier post that evidently wasn't clear. I am building a custom MessageBox dialog that has, among other things, a few new button options (yes to all, no to all, etc.)...
8
by: Saso Zagoranski | last post by:
Hi! I'm trying to make my own MessageBox... What I would like to know is, how the MessageBox class is implemented? I could have something like: new MyMessageBox().ShowDialog(); but I would...
4
by: Tressa | last post by:
I have a messagebox that I only want to pop up only if it is not already being displayed on the screen. My code is still poping up the messagebox even though it is on the screen. What am I doing...
0
by: alex_f_il | last post by:
The class centers MessageBox inside the parent rectangle. Enjoy! using System; using System.Windows.Forms; using System.Text; using System.Drawing; using System.Runtime.InteropServices; ...
20
by: Peter E. Granger | last post by:
I'm having a strange problem (or at least it seems strange to me) trying to display a MessageBox in a VC++ .NET forms application. If I put the call to MessageBox::Show in the form's .h file, it...
4
by: Adam | last post by:
I am trying to inherit from MessageBox and i get error in compilation time. The code is: public class MyMessageBox : MessageBox { public static DialogResult Show(int errorCode) { return...
2
by: GTalbot | last post by:
Hello fellow comp.infosystems.www.authoring.stylesheets colleagues, Imagine this situation: #grand-parent-abs-pos { height: 400px; position: absolute; width: 600px; }
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.