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 }); }
Visual studio provide the best features to design the form. By the designer window, you can add the controls from the toolBox. After added the items, you can set the properties by the property window. Same this things, you can do this by the code window. Follow some steps to add controls dynamically.
Step-1 : Open Code window that is form1.cs file, create a object for controls like
TextBox t1 = new TextBox();
Step-2 : Associate properties of the TextBox class with the current object like
t1.Name = "Text1";
t1.Width = 300;
t1.Text = " Dynamically added Control";
t1.Location = new Point(10, 10);
Here Point is a class, in which you have to define the coordinates of x-axis and y-axis, where you want to add the TextBox.
Step-3 : Add this instance in the form by following line of code.
this.Controls.Add(t1);
Now code Generate the following output:
Step-1 : Open Code window that is form1.cs file, create a object for controls like
TextBox t1 = new TextBox();
Step-2 : Associate properties of the TextBox class with the current object like
t1.Name = "Text1";
t1.Width = 300;
t1.Text = " Dynamically added Control";
t1.Location = new Point(10, 10);
Here Point is a class, in which you have to define the coordinates of x-axis and y-axis, where you want to add the TextBox.
Step-3 : Add this instance in the form by following line of code.
this.Controls.Add(t1);
Now code Generate the following output:
Comments
Post a Comment