Click here to Skip to main content
15,888,263 members
Home / Discussions / C#
   

C#

 
GeneralRe: Project Help Pin
PIEBALDconsult25-Aug-10 15:21
mvePIEBALDconsult25-Aug-10 15:21 
GeneralRe: Project Help Pin
Richard MacCutchan25-Aug-10 22:47
mveRichard MacCutchan25-Aug-10 22:47 
AnswerRe: Project Help Pin
Abhinav S25-Aug-10 5:57
Abhinav S25-Aug-10 5:57 
AnswerRe: Project Help Pin
Pete O'Hanlon25-Aug-10 13:07
mvePete O'Hanlon25-Aug-10 13:07 
AnswerRe: Project Help Pin
Luc Pattyn25-Aug-10 13:39
sitebuilderLuc Pattyn25-Aug-10 13:39 
GeneralRe: Project Help Pin
PIEBALDconsult25-Aug-10 15:17
mvePIEBALDconsult25-Aug-10 15:17 
GeneralRe: Project Help Pin
Luc Pattyn25-Aug-10 15:30
sitebuilderLuc Pattyn25-Aug-10 15:30 
QuestionRun Time Error in simple C# windows app [Solved] Pin
Abhishrek24-Aug-10 23:19
Abhishrek24-Aug-10 23:19 
Hello everyone,

I am a freshman in C# and stuck with a stupid problem.

class ProjectDoc
{
         // there is a panel in the form //
         private System.Windows.Forms.Panel panelProjectDoc;
         this.panelProjectDoc = new System.Windows.Forms.Panel();
         this.Controls.Add(this.panelProjectDoc);
   
        public Point myfunc(Point dropPoint)
        {
            int X_snap = 0;
            int Y_snap = 0;
            //  .... do something .... //
            return new Point(X_snap, Y_snap);
        }

        private void Filter_Click(object sender, EventArgs e)
        {
            BuildBlock buildBlock = new BuildBlock();
            this.panelProjectDoc.Controls.Add(buildBlock);
            buildBlock.Location = myfunc(new Point(900, 400));  // This works OK //
        }
}

class BuildBlock : UserControl
{
        private void BuildBlock_MouseUp(object sender, MouseEventArgs e)
        {
            Point p = new Point(0, 0);
            Point q = new Point(0, 0);
            p = this.Location;
            q = (Parent as ProjectDoc).myfunc(p); // ----- Run Time ERROR on this line ----//
            this.Location = q;
        }
}


Above code gives run time error when mouseUp event occurs.
[ System.NullReferenceException ]

However, if i replace the line :

this.panelProjectDoc.Controls.Add(buildBlock);

with
this.Controls.Add(buildBlock);

it does not give error (however, this way is not what i want )
any idea how to eliminate the error ?

- me
AnswerRe: Run Time Error in simple C# windows app Pin
OriginalGriff24-Aug-10 23:46
mveOriginalGriff24-Aug-10 23:46 
GeneralRe: Run Time Error in simple C# windows app Pin
Abhishrek25-Aug-10 17:34
Abhishrek25-Aug-10 17:34 
AnswerRe: Run Time Error in simple C# windows app Pin
Bernhard Hiller25-Aug-10 0:03
Bernhard Hiller25-Aug-10 0:03 
GeneralRe: Run Time Error in simple C# windows app Pin
Sauro Viti25-Aug-10 2:21
professionalSauro Viti25-Aug-10 2:21 
GeneralRe: Run Time Error in simple C# windows app Pin
Luc Pattyn25-Aug-10 2:31
sitebuilderLuc Pattyn25-Aug-10 2:31 
GeneralRe: Run Time Error in simple C# windows app Pin
OriginalGriff25-Aug-10 2:59
mveOriginalGriff25-Aug-10 2:59 
GeneralRe: Run Time Error in simple C# windows app Pin
Luc Pattyn25-Aug-10 3:16
sitebuilderLuc Pattyn25-Aug-10 3:16 
GeneralRe: Run Time Error in simple C# windows app Pin
OriginalGriff25-Aug-10 3:23
mveOriginalGriff25-Aug-10 3:23 
GeneralRe: Run Time Error in simple C# windows app Pin
DaveyM6925-Aug-10 3:38
professionalDaveyM6925-Aug-10 3:38 
GeneralRe: Run Time Error in simple C# windows app Pin
PIEBALDconsult25-Aug-10 15:26
mvePIEBALDconsult25-Aug-10 15:26 
GeneralRe: Run Time Error in simple C# windows app Pin
Luc Pattyn25-Aug-10 15:32
sitebuilderLuc Pattyn25-Aug-10 15:32 
GeneralRe: Run Time Error in simple C# windows app Pin
PIEBALDconsult25-Aug-10 18:44
mvePIEBALDconsult25-Aug-10 18:44 
GeneralRe: Run Time Error in simple C# windows app Pin
Abhishrek25-Aug-10 17:20
Abhishrek25-Aug-10 17:20 
GeneralRe: Run Time Error in simple C# windows app Pin
Abhishrek25-Aug-10 17:22
Abhishrek25-Aug-10 17:22 
QuestionWhat is the best way to do Clone to class that derived from Queue ( code attached ) Pin
Yanshof24-Aug-10 23:07
Yanshof24-Aug-10 23:07 
AnswerRe: What is the best way to do Clone to class that derived from Queue ( code attached ) Pin
Eddy Vluggen25-Aug-10 7:43
professionalEddy Vluggen25-Aug-10 7:43 
QuestionMessage Removed Pin
24-Aug-10 22:10
Subrat Patnaik24-Aug-10 22:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.