|
Lets say we have an interface 'IControl'.
public interface IControl
{
ControlType Type
{
get;
}
int XPos
{
get;
set;
}
int YPos
{
get;
set;
}
}
Lets say we have a baseclass 'ControlBase : IControl'.
public abstract class ControlBase : IControl
{
int _xPos = 0;
int _yPos = 0;
public ControlBase() {}
public ControlBase(int xPos)
{
_xPos = xPos;
}
public ControlBase(int xPos, int yPos)
{
_xPos = xPos;
_yPos = yPos;
}
public int XPos
{
return _xPos;
}
public int YPos
{
return _yPos;
}
}
Lets say we have a baseclass 'ButtonBase : ControlBase'.
public abstract class ButtonBase : ControlBase
{
public override ControlType Type
{
get
{
return ControlType.Button;
}
}
}
}
The only constructor available in ButtonBase is the default constuctor:
ButtonBase button = new ButtonBase();
What I want to do is inherit the ButtonBase(x) and ButtonBase(x, y) constuctor from the ControlBase baseclass whithout writing new code. In other words I want to use ControlBase as a foundation for other classes, using the baseclass as a template.
In the end I'd like to call 'new ButtonBase(10,100)' in my source-code to create a new instance of ControlBase(10, 100) without adding new (Constuctor-) methods to ControlBase.
How can I do this?
Greetzzz miggro
|
|
|
|
|
You need to do this:
public ControlBase(int xPos, int yPos) : base()
Or if you want to select a base constructor that takes some or all of your parameters, you'd do this:
public ControlBase(int xPos, int yPos, object forBase) : base(forBase)
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I'm afraid that's not possible. You have to explicitly define a constructor in ButtonBase, even if it does nothing but call the base class's constructor.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I'm developing a windows service for Windows XP, and I need to be notified of every user-login happening, however, since the service runs as a System service, it will always say "NT AUTHORITY\SYSTEM" as the username. Is it possible to get such a notification for a C# service? or should I recurr to less 'orthodox' ways to do so?
Miguel
char c[13]={77,105,103,117,101,108,32,65,120,100,114,130,115}<br />
for (int i=0;i<13;i++) printf("%c",c[i]);<br />
|
|
|
|
|
I’ve an ActiveX control inserted in a C# Form. On the form there is some other controls like buttons and so on. I like to send all the keyboard inputs to the ActiveX. At this time when I for e.g. press the up-arrow the focus of all the buttons is changing, and that is not want…
_____________________________
...and justice for all
APe
|
|
|
|
|
I can recomend you 2 way:
1 create the event handlers for all controll, for the events you want to sent to teh ActiveX, and from them call ActiveX event handlers.
2 Disable all other controlls in the form, while you want to focused only teh ActiveX
|
|
|
|
|
I have an old dll created in C++ with Visual Studio 6.0 with the Win32 Dynamic link-library project. Is it possible to use that dll in a .NET, C# project?
If, How? I’ve tried to add a reference in VS 2003 to the dll but I got the error that the dll is not a .NET assembly or a COM dll…
_____________________________
...and justice for all
APe
|
|
|
|
|
|
Hi,
I've read the article about Ethernet packet sending and tested the code. All is great. I try to make the same work over windows CE. It's possible to adapt the code for my scope?
Many Thanks
Luca
|
|
|
|
|
Hi all,
I want to generate a report (a CV) with an individual Fotos (Bitmaps) on it. I am using the "pull method" and a XML-Database structure for crystal reports, but loading the report by a dataset.
Does anyone know how to do that (how to tell crystal reports that the field object is a variable bitmap)
and which format to use for on the dataset to supply the correct information ?
Thanks
Frank
|
|
|
|
|
I've got a line chart with the date displayed horizontally across the x axis and would like to display the dates vertical. Is there a way to rotate the group labels on the x axis?
|
|
|
|
|
I am wanting to setup a window in an application I am working on that behaves similar to the Find and Replace windows in Visual Studio where the modeless dialog remains above the main application's window at all times not covering other application's windows. I have tried the TopMost property, but it overlaps other application windows as well which I don't want. Is there a way to implement a topmost-like behavior that doesn't overlap other applications' windows?
Thanks in advance.
John 3:16: "For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life."
|
|
|
|
|
Im not 100% sure but I think setting the Owner property of the dialog to your application main form should do it.
|
|
|
|
|
That did it! Thanks!
John 3:16: "For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life."
|
|
|
|
|
In a C# application:
How to delete a file in a non-permanent manner by sending it to Recycle Bin, instead of deleting it permanently?
I want to do it so that the user will have the option of restoring the file from Recycle Bin if he wants to at a later time.
|
|
|
|
|
You need the Windows Shell API for this.
Use the SHFileOperation.
Check out this[^] article...
/cadi
24 hours is not enough
|
|
|
|
|
Thanks for reply.
But, is it possible to get the "physical address" of the Recycle Bin "virtual" folder in the C# code itself, because in that I can use the File.Move method to move the file to that folder. This may be equivalent to deleting to the Recycle Bin.
|
|
|
|
|
normally it is located under C:\RECYCLER\ + Some string that looks like an SID.
But i think it is not recomendet to move files directly into this folder since you would override the maximum size of the recycler. This could lead to conditions where the recycler grows until it uses all the space of the HD.
But since the recylcer is only available on windows you could use the shell functions. you app would work only on windows anyway.
/cadi
24 hours is not enough
|
|
|
|
|
i need to create a dll that contain form for image viewer.
I want to use this dll inside some my different applications.
How can i do?
|
|
|
|
|
Create a project as a class library,and compile it using the library arguments ,it will be then a dll file ,add a reference to it in any application that you want to use it in.
|
|
|
|
|
I've got a slight problem with @-quoted strings in C#. I'm reading some XML formatted data using a XmlTextReader. At some point in this process I get a chunk of text that contains some escape sequences. I want to use this as the format part in an StringBuilder.AppendFormat() method.
StringBuilder sb = new StringBuilder() ;<br />
string format = myXmlTextReader.Value ;<br />
sb.AppendFormat(format, ...) ;
However the value in format is @-quoted. If I look in the debugger it shows the following:
format = @"The user says\n{0}"
I just can't work out how to un @-quote the string in code. I want the newline in the string not the \n. There must be a simple way to do this but I just can't find it!
TIA Jackson
|
|
|
|
|
Er... it IS unquoted.
It is only displayed as verbatim string (otherwise it would contain a CR that wóuld not look so nice in the IDE's watch window).
Do not use the debugger but try a Console.Out.WriteLine(format); to verify my claim.
/cadi
24 hours is not enough
|
|
|
|
|
The debugger always shows all strings verbatim. Try printing to the console and see if it works correctly.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Well - I've added the following two lines to the app:
System.Console.WriteLine(format);<br />
System.Console.WriteLine("test\nstring");
And this produces the following in the Output Window:
The user says\n{0}<br />
test<br />
string
Just to confuse things further before I display the final string from the StringBuilder I looked at the value in the string and the debugger shows the following:
msg="Test Dynamic Form\nLess than 20 users impacted\nNo you can't\nNO VALUE SELECTEDThe user says\\nTest"
The debugger does not show the @ for a @-quoted string this time and the final \n has been escaped! It isn't escaped when its in the variable format - just to be sure i replaced all occurances of \ with ! and printed out the result.
So - still confused here
|
|
|
|
|
Oops. My bad. The debugger doesn't show all strings verbatim, it shows them only for
1. those that have the @ and have escaped characters, for eg, @"senthil\n".
2. those that don't have an @ but still have escaped characters, like "senthil\\". "\n", "\t" seem to be exceptions to this rule.
Anyway, your problem is because format has a literal \n in it, that is, format = @"The user says \n". You'd need to search for the literal \n ("\\n" or @"\n") and replace it with the line breaking character. In short
string x = @"senthil\n";
string y =x.Replace(@"\n", "\n");
Console.WriteLine(y);
will do what you want.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|