Articles → LIGHT SWITCH 2011 → Enable Multi Selection In Grid In Lightswitch 2011

Enable Multi Selection In Grid In Lightswitch 2011






Software Requirement




  1. Visual studio 2010 is installed on your machine.
  2. Visual Studio 2010 service pack 1 is installed on your machine.
  3. Microsoft Visual Studio Light switch 2011 is installed on your machine.

Prerequisite Knowledge




  1. How to create lightswitch project?
  2. How to create an entity in lightswitch?
  3. How to create a screen in lightswitch?
  4. What is ControlAvailable event in lightswitch?

Steps Of Execution




  1. Creation of new project.
  2. Creation of new table.
  3. Creation of new screen.
  4. Add data to table.
  5. Add ControlAvailable event in screen’s created event.
  6. Set the grid’s SelectionMode property.




Picture showing the project structure of the lightswitch application in the solution explorer of visual studio

Click to Enlarge



Picture showing the Employee entity in the lightswitch designer

Click to Enlarge



Picture showing the designer screen of the Editable Grid Screen

Click to Enlarge



Picture showing the data added in the editable grid screen

Click to Enlarge



partial void EditableEmployeesGrid_Created(){
  // Write your code here.
  this.FindControl("grid").ControlAvailable += new EventHandler<ControlAvailableEventArgs>(EditableEmployeesGrid_ControlAvailable);   
}




Partial void EditableEmployeesGrid_Created(){
            // Write your code here.
            this.FindControl("grid").ControlAvailable += new EventHandler<ControlAvailableEventArgs>(EditableEmployeesGrid_ControlAvailable);   
}

void EditableEmployeesGrid_ControlAvailable(object sender, ControlAvailableEventArgs e){
   if (e.Control is DataGrid)   {
         DataGrid grid = (DataGrid)e.Control;
         grid.SelectionMode = DataGridSelectionMode.Extended;
   }
}





Output


Picture showing the multiple selection of grid in lightswitch

Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Wednesday, November 21, 2012

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250