Skip to main content Skip to footer

Using the New Windows 11 System Icons with ComponentOne Ribbon

Quick Start Guide
What You Will Need

ComponentOne WinForms Edition

Visual Studio 2022

Controls Referenced

C1Ribbon

C1Bitmap

Tutorial Concept Learn how to take advantage of the .NET 8 system icons in your ribbons and toolbars for Windows 11 applications.

The SystemIcons class is a powerful new addition to .NET 8.0. It provides easy access to Windows system-wide icons, allowing developers to enhance their applications with familiar visual elements. Each property of the SystemIcons class represents an Icon object associated with a specific system icon.

In this blog, we'll explore:

Why Use the New SystemIcons?

The SystemIcons class in .NET offers a convenient way to access predefined standard icons for Windows system-wide use. By using SystemIcons, you can ensure that your application’s icons match the standard icons used throughout the Windows operating system, enhancing the overall user experience. If your application targets Windows specifically, leveraging SystemIcons can enhance visual consistency and familiarity for your users.

Using SystemIcon with C1Ribbon

In this example, we will learn how to programmatically change the icon of RibbonButton in the C1Ribbon to the Windows 11 folder icon.

First, we will start with a basic C1Ribbon and Ribbon Button with no icon set.

Basic C1Ribbon

We can use the following code to programmatically set the Button icon to the Windows 11 folder icon. We will implement the C1BitmapIcon to help handle the new SystemIcon:

//Folder Icon
C1BitmapIcon folderIcon = new C1BitmapIcon();
folderIcon.Source = new Bitmap(SystemIcons.GetStockIcon(StockIconId.Folder).ToBitmap());
folderIcon.Size = new Size(16, 16);

ribbonButton1.IconSet.Clear();
ribbonButton1.IconSet.Add(folderIcon);

We now have a Windows 11 folder icon for our C1Ribbon button:

Windows 11 Folder icon

SystemIcons Properties

The SystemIcons class in .NET provides access to numerous predefined system-wide icons. The table below lists some of the icons available for use:

Application Gets an Icon object that contains the default application icon (WIN32: IDI_APPLICATION).
Asterisk Gets an Icon object that contains the system asterisk icon (WIN32: IDI_ASTERISK).
Error Gets an Icon object that contains the system error icon (WIN32: IDI_ERROR).
Exclamation Gets an Icon object that contains the system exclamation icon (WIN32: IDI_EXCLAMATION).
Hand Gets an Icon object that contains the system hand icon (WIN32: IDI_HAND).
Information Gets an Icon object that contains the system information icon (WIN32: IDI_INFORMATION).
Question Gets an Icon object that contains the system question icon (WIN32: IDI_QUESTION).
Shield Gets an Icon object that contains the shield icon.
Warning Gets an Icon object that contains the system warning icon (WIN32: IDI_WARNING).
WinLogo Gets an Icon object that contains the Windows logo icon (WIN32: IDI_WINLOGO).

Additional SystemIcons with C1Ribbon

As you can see, there are many different graphics we can use with SystemIcons. Below is an example of using the Windows 11 information and Delete icons with additional C1Ribbon buttons:

//Folder Icon
C1BitmapIcon folderIcon = new C1BitmapIcon();
folderIcon.Source = new Bitmap(SystemIcons.GetStockIcon(StockIconId.Folder).ToBitmap());
folderIcon.Size = new Size(16, 16);

ribbonButton1.IconSet.Clear();
ribbonButton1.IconSet.Add(folderIcon);

//Information Icon
C1BitmapIcon infoIcon = new C1BitmapIcon();
infoIcon.Source = new Bitmap(SystemIcons.GetStockIcon(StockIconId.Info).ToBitmap());
infoIcon.Size = new Size(16, 16);

ribbonButton2.IconSet.Clear();
ribbonButton2.IconSet.Add(infoIcon); 

//Delete Icon
C1BitmapIcon deleteIcon = new C1BitmapIcon();
deleteIcon.Source = new Bitmap(SystemIcons.GetStockIcon(StockIconId.Delete).ToBitmap());
deleteIcon.Size = new Size(16, 16);

ribbonButton3.IconSet.Clear();
ribbonButton3.IconSet.Add(deleteIcon);

Additional Icons

Conclusion

The SystemIcons in .NET 8.0 is a valuable addition for developers aiming to enhance their applications with familiar and consistent visual elements. By leveraging the predefined standard icons provided by SystemIcons, developers can ensure their applications align with the visual standards of the Windows operating system, thereby improving user experience and interface consistency. Whether you’re updating existing applications or developing new ones, incorporating SystemIcons can significantly streamline the process of managing and applying system-wide icons.

comments powered by Disqus