#1
  1. Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    8
    Rep Power
    0

    Defining form objects in classes


    Hi,
    I'm starting to learn C#, and so far am happy to say have been quite successful in coming to terms with the langauge use etc, but I need help!

    I am trying to define form objects in a class:

    PHP Code:
    public class atitle {
        
    int xint yint wint h;
        
    string paneluse;

        private 
    System.ComponentModel.Container components null;
        private 
    System.Windows.Forms.Panel activepanel;

        
    activepanel = new System.Windows.Forms.Panel();

        
    activepanel.Location = new System.Drawing.Point (xy);
        
    activepanel.Name "panel_"+paneluse;
        
    activepanel.Size = new System.Drawing.Size(wh);
        
    activepanel.TabIndex 0;

        public 
    void activepanel_click (object senderSystem.EventArgs e){
            
    //do stuff
        
    }

    but this code produces compiler errors (I am using Borland C# Builder).
    I would really appreciate it if someone could show me the correct code to use

    Thanks in advance,
    -hammerhead
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    486
    Rep Power
    12
    show us the errors it's got out. That might help us.
  4. #3
  5. Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    8
    Rep Power
    0
    Microsoft (R) Visual C# .NET Compiler version 7.10.3052.4
    for Microsoft (R) .NET Framework version 1.1.4322
    Copyright (C) Microsoft Corporation 2001-2002. All rights reserved.

    WinForm.cs(21,15): error CS1519: Invalid token '=' in class, struct, or interface member declaration
    WinForm.cs(21,47): error CS1519: Invalid token '(' in class, struct, or interface member declaration
    WinForm.cs(23,24): error CS1519: Invalid token '=' in class, struct, or interface member declaration
    WinForm.cs(23,50): error CS1519: Invalid token '(' in class, struct, or interface member declaration
    WinForm.cs(23,52): error CS1519: Invalid token ',' in class, struct, or interface member declaration
    WinForm.cs(23,55): error CS1519: Invalid token ')' in class, struct, or interface member declaration
    WinForm.cs(24,20): error CS1519: Invalid token '=' in class, struct, or interface member declaration
    WinForm.cs(24,39): error CS1519: Invalid token ';' in class, struct, or interface member declaration
    WinForm.cs(25,20): error CS1519: Invalid token '=' in class, struct, or interface member declaration
    WinForm.cs(25,45): error CS1519: Invalid token '(' in class, struct, or interface member declaration
    WinForm.cs(25,47): error CS1519: Invalid token ',' in class, struct, or interface member declaration
    WinForm.cs(25,50): error CS1519: Invalid token ')' in class, struct, or interface member declaration
    WinForm.cs(26,24): error CS1519: Invalid token '=' in class, struct, or interface member declaration
    WinForm.cs(112,4): error CS1585: Member modifier 'private' must precede the member type and name
    Those are the errors I got.
    Thanks for the reply
    -hammerhead
  6. #4
  7. Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    8
    Rep Power
    0
    Does no-one know?
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    486
    Rep Power
    12
    long time since I worked in C and C++ and that's even C#.

    looks like you got some errors !

    imo that doesn't look kinda right

    Code:
    private System.Windows.Forms.Panel activepanel;
    
        activepanel = new System.Windows.Forms.Panel();
    activepanel is already declared as a panel. Usually you got a variable that you declare a name of another objet no ?

    If that's the error then all others errors are probably related to this.
    I would say to check that out, I might be wrong but at first look it doesn't look that nice.

    probably someone else here could give their opinions and tell you more about it....

IMN logo majestic logo threadwatch logo seochat tools logo