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 }); }
Common dialog class is the base class for displaying common dialog boxes. One can access these boxes like Font dialog box, Open dialog box, Print dialog box etc. by using inherited classes of this base class. All these inherited classes overrides RunDialog() method which is automatically called when user calls the ShowDialog() method.
To add this box just drag-n-drop color dialog control from the toolbox. Add a textbox and two buttons on the form with text property background and foreground respectively as shown in the following image:
Write the following code snippet (C# language) in click event of both button respectively:
So it is so easy to change color of any control’s background or foreground property.
FontDialogBox Control
Color Dialog Box
To change the color of anything you want like text color, background color or foreground color of any control dynamically, we can use color dialog box. A simple look on color dialog box:To add this box just drag-n-drop color dialog control from the toolbox. Add a textbox and two buttons on the form with text property background and foreground respectively as shown in the following image:
Write the following code snippet (C# language) in click event of both button respectively:
private void backgroundButton_Click(object sender, EventArgs e)
{
colorDialog1.ShowDialog();
textBox1.BackColor = colorDialog1.Color;
}
private void foregroundButton_Click(object sender, EventArgs e)
{
colorDialog1.ShowDialog();
textBox1.ForeColor = colorDialog1.Color;
}
Now look out the text box, it have been changed its background color to and also foreground color as shown in following image.{
colorDialog1.ShowDialog();
textBox1.BackColor = colorDialog1.Color;
}
private void foregroundButton_Click(object sender, EventArgs e)
{
colorDialog1.ShowDialog();
textBox1.ForeColor = colorDialog1.Color;
}
So it is so easy to change color of any control’s background or foreground property.
FontDialogBox Control
Comments
Post a Comment