Chinese (People's Republic of China)  English  Français


Supinfo-Projects.com
Supinfo Students' projects



Projects
  Last project
  Top projects
  All projects

77 User's online
3168 Projects


My Supinfo-Projects

   Login
   Create account


Synopsis

   6 Hits
   Visitors Score : 20
    (3 Voter)
   0 Comments

   Read the article

Evaluate this article

20
18
16
14
12
10
8
6
4
2
0


Comment this article

Author :

Email :

Your comment :



 
2006 - Pérennisation
Use and customize of host of forms of Visual Studio 2005 in your applications .net
[30 mn of reading - published 6/6/2006 8:37:04 PM - Target : Confirmé]

Author

wildarkWilliam GUIOUBLY
Student-Engineer Supinfo Paris
SUPINFO graduate year  2007

   Write to the person
   All projects of the same author
   Mini-CV of the author

3 The IDesignerHost service

The IDesignerHost service is an interface of the namespace System.ComponentModel.Design. It provides methods and properties which allow the management of the controls and the transactions on the control container thus to know its state (To consult the MSDN to know all its methods, properties and events). One recovers this service via the GetService method of the DesignSurface class, while passing the type System.ComponentModel.Design.IDesignerHost in parameter. 

 

Let us examine somebody of these methods, properties and events:

- The RootComponent property which represents the control container of the originator.

- The Container property which make it possible to know the control container and controls children which are associated there.

- The CreateComponent method which makes it possible to create controls children which could be added to the control container

- The DestroyComponent method which makes it possible to destroy the controls children associated with the control container.

- The CreateTransaction method which makes it possible to create transactions. 

- The Activate method to activate the originator.

 

IDesignerHost is a service by default of the class DesignSurface, it is not necessary to add it except if you wish to personalize it.

 

Let us illustrate our presentation for an example. We will create a button and a textBox. We will modify the Form1_Load event as follows:

private void Form1_Load(object sender, EventArgs e)

{

    designer = new Designer();

    designer.BeginLoad(typeof(Form));

 

    if (!designer.IsLoaded)

        throw new Exception("Le concepteur n'a pu être chargé");

 

    ((Control)designer.View).Dock = DockStyle.Fill;

    panel1.Controls.Add((Control)designer.View);

 

    // Select the service IDesignerHost

    System.ComponentModel.Design.IDesignerHost host =

 (System.ComponentModel.Design.IDesignerHost)

designer.GetService(typeof(System.ComponentModel.Design.IDesignerHost));

 

    // Create a button

    IComponent button = host.CreateComponent(typeof(Button));

    ((Control)button).Location = new Point(5, 10);

    ((Control)button).Text = "Bouton";

 

    // Add it at control container

    ((Form)host.RootComponent).Controls.Add((Control)button);

 

    // Create a textbox

    IComponent textBox = host.CreateComponent(typeof(TextBox));

    ((TextBox)textBox).Location = new Point(5, 50);

 

    // Add it at control container

    ((Form)host.RootComponent).Controls.Add((Control)textBox);

}

 

 To compile and launch the project and here what you obtain:

Exemple Designer Host.JPG

One can see the button and the texbox created which one can select, reposition and resize.



Articles de la même catégorie

 Pages : Top


5 Hits
0 Comments
ID3 and C4.5 algorithms
[40 mn of reading - published 6/6/2006 7:48:47 PM - Target : Confirmé]

More


9 Hits
0 Comments
Generics with .NET
[30 mn of reading - published 6/6/2006 3:37:29 PM - Target : Confirmé]

More


5 Hits
0 Comments
Widget Development
[10 mn of reading - published 6/6/2006 3:03:12 PM - Target : Débutant]

More

Powered by Campus-Booster Technology
Conditions d'utilisation & Copyright | Respect de la vie privée
© Copyright 1965-2006 Supinfo Paris, Paris Academy of Computer Science
Supinfo, Ecole Supérieure d'Informatique et Paris Academy Of Computer Science are trade marks.
23, rue de Château LANDON - 75010 PARIS - Phone : +33 (0) 153359 700 Fax : +33 (0) 153359 701

Web site autided by :