You are busy developing a Microsoft Windows Forms application. The application will be shrink-wrapped and sold to end users. The application is specified so that if a user installs it, it will uses the user’s display preferences to create Help images for each form in the application.
Which of the following code segments should you use to allow the application to update the image if a user changes system colors? (Select two)
A.
SystemColorsChanged +=delegate
{
//Update the Help images
}
B.
SystemEvents.UserPreferenceChanged += delegate[object sender, UserPreferenceChangedEventArgs e]
{
if [e.Category == UserUserPreferenceCategory.Color] {
SystemColorChanged += delegate
{
//Update the Help images
}
}
}
C.
SystemEvents.UserPreferenceChanged += delegate[object sender, UserPreferenceChangedEventArgs e]
{
if [e.Category == UserUserPreferenceCategory.Color] {
//Update the Help images
}
}
D.
SystemEvents.UserPreferenceChanged += delegate
{
//Update the Help images
}
Explanation:
When a preference is changed, the common language runtime raises the UserPreferenceChanged event. And even the handler should be attached to the event and update the Help images if the Category property is set to color.Incorrect Answers:
B, D: It is not necessary to update the Help images when the UserPreferenceChanged event is raised. When the UserPreferenceChanged event is raised, you should not handle the SystemColorChange and update the Help images.A SystemColorsChanged gibt es – Tritt ein, wenn sich die Systemfarben ndern.
C SystemEvents.UserPreferenceChanged liefert in e.Category die genderte Eigenschaft !!