I want to show Components in a tabs , so first of all create few components. In this project we have three components, First View Component public class AllViewComponent : ViewComponent { private readonly UserManager<ApplicationUser> _userManager; public AllViewComponent(UserManager<ApplicationUser> userManager) { _userManager = userManager; } public async Task<IViewComponentResult> InvokeAsync() { List<StudentViewModel> allUsers = new List<StudentViewModel>(); var items = await _userManager.Users.ToListAsync(); foreach (var item in items) { allUsers.Add(new StudentViewModel {Id=item.Id, EnrollmentNo = item.EnrollmentNo, FatherName = item.FatherName, Name = item.Name, Age = item.Age, Birthdate = item.Birthdate, Address = item.Address, Gender = item.Gender, Email = item.Email }); }
As we all know that we don’t want
unauthorized users to let them access our programs, so the better approach is
to use a login form and then run our main application. For that simple task we
have to close our first thread in which login form is running and start a new
thread in which our new form will open.
To
start a new thread Microsoft provides a class i.e. System.Threading.Thread
In Visual Studio 2012 In which some
function have written to play with threads like, Start(), Abort() etc.
First
create a new form named login and set this our default form through program.cs,
now in login form designer window create a new button having text “Start New
thread”. Generate click event of this button and write following set of lines:
Here
appThread is a variable of type System.Threading.Thread
class and LaunchAdminApplication
is a function that have work to do now.
In above code, first we have called the constructor of Thread class that needs a parameter, which is name of function, having the work to do. At the last we call Start() function which causes the operating system to change the state of current instance.
Application.Run() is the same function our program.cs class have which is used to define which form is going to be shown.
So finally Form1 will be the new instance of
this windows form application.
Download Example Here.
Comments
Post a Comment