Articles → LIGHT SWITCH 2011 → Autorefresh lightswitch screen in lightswitch 2011

Autorefresh lightswitch screen in lightswitch 2011





  1. Software requirements
  2. Prerequisite knowledge
  3. Creation of new project
  4. Add Employee entity in the project
  5. Add Editable grid screen
  6. Add records in the table
  7. Add timer in the screen

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. What is lightswitch?
  2. What are screens and entities in lightswitch?
  3. How to create an entity in lightswitch?
  4. How to create screens in lightswitch?

Creation of new project




Picture showing the project structure of the lightswitch project

Click to Enlarge


Add Employee entity in the project




Picture showing the schema of Employee table in lightswitch

Click to Enlarge


Add Editable grid screen




Picture showing the editable grid screen added in the project

Click to Enlarge


Add records in the table




Picture showing records added in the lightswitch project

Click to Enlarge


Add timer in the screen




using System;
using System.Collections.Generic;
using Microsoft.LightSwitch;
using System.Windows.Threading;
using Microsoft.LightSwitch.Threading;

namespace LightSwitchApplication {
	public partial class EditableEmployeesSetGrid {
		partial void EditableEmployeesSetGrid_InitializeDataWorkspace(List < IDataService > saveChangesTo) {
			Dispatchers.Main.BeginInvoke(() = >{
				Timer.Tick += new EventHandler(Each_Tick);
				Timer.Start();
			});

		}

		private static readonly DispatcherTimer Timer = new DispatcherTimer() {
			Interval = TimeSpan.FromSeconds(5) // Create a timer to refresh screen
		};

		private void Each_Tick(object sender, EventArgs e) {
			Dispatchers.Main.BeginInvoke(() = >{
				EmployeesSet.Refresh();
			});
		}
	}
}







Posted By  -  Ritesh Arya
 
Posted On  -  Wednesday, September 19, 2012

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250