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


Supinfo-Projects.com
Supinfo Students' projects



Projects
  Last project
  Top projects
  All projects

190 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

4 The ISelectionService service

The ISelectionService service is an interface of the namespace System.ComponentModel.Design. It provides methods and properties which allow the selection of the controls on the originator (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 System.ComponentModel.Design.ISelectionService type in parameter. 

 

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

- The PrimarySelection property which turns over the first selected control.

- The SelectionCount property which turns over the number of selected controls.

- GetComponentSelected which indicate if the control in parameter is in the S 3rd lection in progress

- The GetSelectedComponents method which return the selected controls.

- The SetSelectedComponents method which permit to define the selected controls.

- The SelectionChanged event which occurs when the selection is modified.

- The SelectionChanging event which occurs when the selection is about to be modified

 

ISelectionService 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 modify the code as follows:

 

private void Form1_Load(object sender, EventArgs e)

{

   

 

    // Récupération du service ISelectionService

    System.ComponentModel.Design.ISelectionService selectionService =

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

 

    // Add the evenement SelectionChanged

    selectionService.SelectionChanged += new EventHandler(selectionService_SelectionChanged);

 

    // Assocation the control container to the propertyGrid

    propertyGrid1.SelectedObject = host.RootComponent;

}

 

void selectionService_SelectionChanged(object sender, EventArgs e)

{

    System.ComponentModel.Design.ISelectionService selectionService = (System.ComponentModel.Design.ISelectionService)sender;

 

    // Creation of the list of controls sélectionned

    IComponent[] listSelection = new IComponent[selectionService.SelectionCount];

    selectionService.GetSelectedComponents().CopyTo(listSelection, 0);

 

    // Association the controls selected to the propertyGrid

    propertyGrid1.SelectedObjects = listSelection;

}

 

// Release the ressources

private void Form1_FormClosing(object sender, FormClosingEventArgs e)

{

    // Release the evenements on the service of IComponentChangeService    System.ComponentModel.Design.ISelectionService selectionService =

         (System.ComponentModel.Design.ISelectionService)

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

   

    selectionService.SelectionChanged -= new EventHandler(selectionService_SelectionChanged);

 

    // Delete the view of designer of panel

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

 

    // Release the designer to the form

    designer.Dispose();

}

           

We will use the ISelectionService service for associated the selections with the propertyGrid. 

 

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

 

Exemple IselectionService.JPG

 

You can select the components (also multiple selection) like modifying their properties in the propertyGrid.



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 :