|
Paul Riley wrote:
You can't create an instance of an abstract class because an abstract class has no implementation, just a list of virtual functions. You can't create an instance of an interface because it's just a list of function definitions (a contract for any inheriting class).
That explained all I needed to know! MyControl is really abstract, I am @ home now, I will post the code when I get to work..
Thanks!
|
|
|
|
|
public abstract class MyControl : System.Web.UI.UserControl
{
public int countoftext = 0;
public string myType;
public string labelname = "";
public Label mylabel;
public int positiontop = 25;
public int positionleft = 100;
public MyControl tempcontrol = new MyControl();
private void Page_Load(object sender, System.EventArgs e)
{
}
private void ReadMenu()
{
XmlTextReader xmlreader = new XmlTextReader("menu.xml");
while (xmlreader.Read())
{
myType = xmlreader.NodeType.ToString();
if (myType.Equals("Text"))
{
countoftext++;
mylabel = new Label();
mylabel.Text = xmlreader.Value;
mylabel.Style["Position"]="Absolute";
mylabel.Style["Top"] = "" + positiontop +"px";
mylabel.Style["Left"] = "" + positionleft + "px";
tempcontrol.Controls.Add(mylabel);<--WONT WORK
}
}
positiontop = positiontop + 20;
xmlreader.MoveToNextAttribute();
}
I guess I wont use a user control and just do it directly from the form. Oh, and some of the code may seen wrong, I am still learning C#, the code actually does work though, because I was able to display other properties without creating labels on the WebForm1.aspx that was using the custom user control, like showing the Encoding of elements in my xml file, or the count, etc blah ..
|
|
|
|
|
This doesn't look very abstract to me. What happens if you take the word out completely?
By the way, I wouldn't advise creating an instance of a class in the definition for that class. The new instance will also create a new instance, the new new instance will then create another one, and so on.
Dangerous ground, I'm surprised it compiles. (unless I'm missing something fundamental)
Paul
Life is just a sexually transmitted desease - Matthew Wright (ex-journalist, TV presenter) 10-Oct-02
I finally have a sig! - Paul Riley (part-time deity) 10-Oct-02
|
|
|
|
|
I am trying to detect when the user clicks on the actual tab of a tabcontrol object in order to display a context menu.
I don't want to put the context menu in the associated property of the tabcontrol because it will automatically pop up when the user clicks anywhere on the tabcontrol.
I just want to detect when the user clicks on the actual tab.
Can someone help me out?
Darryl Borden
Principal IT Analyst
darryl.borden@elpaso.com
|
|
|
|
|
Hi All,
If there is an unmanaged code in a application then how does the compiler handle that unmanaged code.Is the unmanaged code directly compiled into native code without first converting into MSIL or is there some mechanism with the compiler to handle such unmanaged code and thus convert it into MSIL.I would like to know how this processing of the unmanaged code is done by the compiler.
Thanks
Abhishek.
Learning is a never ending process of Life.
|
|
|
|
|
I'm presuming that you're talking about C++ code, since there is not unmanaged C# code.
For C++ code, the code that is compiled with /clr is compiled to IL. Code without that is compiled to native. C++ supports having both managed and unmanaged code in the same exe.
|
|
|
|
|
Can somebody tell me exactly what order events are fired when a form displays. I want to do some processing immediately *after* the form has been displayed, and not before which happens if I put the code in the constructor. Which event handler is best to override to do this? I tried VisibleChanged, but that fires when ever the visiblity changes (including when the form closes) and not just the first time.
Thanks
|
|
|
|
|
|
You could use the Form Load or Activated events. In the case of Activated, you may need to set a boolean variable to prevent taking care of your action twice.
Gaul
|
|
|
|
|
Actually the Load event fires before the form is loaded, but the activated event works just fine.
|
|
|
|
|
Hi,Everyone!!
make string = "31323334" ('31','32' ... is HEX) to string = "1234"???
who can help me?
|
|
|
|
|
Are you dealing with just numbers, or letters too: 656667="ABC"? If you're dealing with just numbers, you could employ a cute trick and get rid of the first, third, fifth, etc. '3' character (I can't remember if 30=ASCII '0' though).
Marc
|
|
|
|
|
Hi all,
using System.Runtime.InteropServices;
...
[DllImport("ole32.dll")]
public static extern long CLSIDFromProgID(string ProgID, out Guid clsID);
...
Guid clsID;
long ret = CLSIDFromProgID("Excel.Application", out clsID);
if(ret==0)
System.Console.WriteLine("OK.");
else
System.Console.WriteLine("Fail.");
I use above codes for checking Microsoft Excel is installed or not. But it doesn't work at all, even if I already installed Microsoft Excel.
Are there any missing in my codes?
|
|
|
|
|
[DllImport("ole32.dll", CharSet=CharSet.Auto)]
She's so dirty, she threw a boomerang and it wouldn't even come back.
|
|
|
|
|
Hi Stephane,
Thanks for your help.
I changed my codes as you suggest but it still doesn't work. I think I don't set type of parameters accurately.
Do you think my declaration below is correct?
[DllImport("ole32.dll", CharSet=CharSet.Auto)]
public static extern long CLSIDFromProgID(string ProgID, out Guid clsID);
Many thanks.
|
|
|
|
|
The return type is a 32-bit integer, which is int , not long .
Have you tried:
Type Excel = Type.GetTypeFromProgID("Excel.Application");
if (Excel == null)
Console.WriteLine("Fail.");
else
Console.WriteLine("OK.");
|
|
|
|
|
Can you explain what you're trying to do?
If you're trying to drive excel, you'd do that through COM interop, not through P/Invoke. You do that by adding the excel com component to your project (or through tlbimp if you don't have vs).
|
|
|
|
|
How would such an interop assembly behave on a system where excel is not installed? Would it crap out on me while loading the application or would it throw a bunch of exceptions at me when I try to instantiate the COM-objects?
--
Please state the nature of your medical emergency.
|
|
|
|
|
Hmm. I don't know the answer to that.
|
|
|
|
|
|
I didn't know we'd made those available.
The page you link is correct, you should use the primary interop assemblies rather than rolling your own.
|
|
|
|
|
Eric Gunnerson (msft) wrote:
you should use the primary interop assemblies rather than rolling your own
Any special reason for this?
--
Please state the nature of your medical emergency.
|
|
|
|
|
The big reason is that they're signed.
|
|
|
|
|
Eric Gunnerson (msft) wrote:
The big reason is that they're signed.
Sounds like political red tape typical from any company, am I right?...
Nick Parker
The goal of Computer Science is to build something that will last at least until we've finished building it. - Unknown
|
|
|
|
|
Nick Parker wrote:
Sounds like political red tape typical from any company, am I right?...
I don't understand your point.
|
|
|
|