3
Answers

NP125 activation from “Add Reference…”

Maha

Maha

16y
1.9k
1

Hi Guys

 

NP125 activation

 

In the following program activation of System.Windows.Forms from “Add Reference…” and inclusion of that in the namespace is necessary for program to execuate but as long as System.Drawing is concerned only activation is necessary, not needed that to include  in the namespace for the program to execuate. What is the reason for that?     

 

Please explain.

 

Thank you

 

//p332

 

using System;

using System.Windows.Forms;

using System.Drawing;

 

//descends from the From class

public class WindowWithButton : Form

{

    Button button1 = new Button();  //Button object named button1

 

    public WindowWithButton() //constructor

    {

        this.Size = new System.Drawing.Size(300, 300);

        //Size field for the Form

 

        this.Text = "Window Object With Button";

        //Text field for the Form

 

        button1.Text = "Press";     //Text field for the Button

 

        this.Controls.AddRange(new System.Windows.Forms.Control[] { this.button1 });

 

        /*

        Controls.AddRange() method to indicate that the Button

  you created will become one of the Form's usable controls.

        */

 

        this.button1.Location = new System.Drawing.Point(100, 50);

        //locate the Button at position 100, 50 on the Form

    }

    //Main() method to execuate the application

    public static void Main()

    {

        Application.Run(new WindowWithButton());

    }

}

Answers (3)