Skip to content

koszeggy/KGySoft.WinForms

Repository files navigation

KGy SOFT .net

KGy SOFT WinForms Libraries

KGy SOFT WinForms Libraries offer advanced Windows Forms controls and other useful components for .NET Framework and .NET Core applications. The libraries support every Windows version starting with Windows XP, and every platform target starting with .NET Framework 3.5 and .NET Core 3.0.

GitHub Repo Nuget

Table of Contents:

  1. Download
  2. Release Notes
  3. Examples
  4. License

Download

The binaries can be downloaded as a NuGet package directly from nuget.org

However, the preferred way is to install the package in VisualStudio either by looking for the KGySoft.WinForms package in the Nuget Package Manager GUI, or by sending the following command at the Package Manager Console prompt:

PM> Install-Package KGySoft.WinForms

Release Notes

See the change log.

Examples

Advanced Common Controls

Overview

The KGy SOFT WinForms libraries contain several advanced controls that are all derived from the standard Windows Forms controls, but offer with additional features and fixes for common issues. These controls include: AdvancedButton, AdvancedCheckBox, AdvancedComboBox, AdvancedDateTimePicker, AdvancedLabel, AdvancedProgressBar, AdvancedRadioButton and AdvancedTextBox.

Exception with AdvancedProgressBar, they all support custom disabled colors (which is normally not adjustable) and fixed auto font scaling when the application has per-monitor DPI awareness enabled. Additionally, AdvancedButton, AdvancedCheckBox, AdvancedRadioButton and AdvancedLabel support buffered fading animations with every flat style. See more details in the following sections.

💡 Tip

Try the example application from the KGySoft.WinForms.Example folder or download its binaries from the Releases.

A TaskDialog in the KGySoft.WinForms.Example application
Advanced controls selector dialog for testing in the KGySoft.WinForms.Example application

Advanced Base Controls

To implement your own advanced controls, you can derive from the BaseControl, BaseUserControl and BaseForm classes. Most notable features:

  • They remove all event subscriptions when disposed.
  • All have an InvokeOnUIThread method. It is similar as combining InvokeRequired and Invoke, but works correctly even when the control is not created yet, in which case InvokeRequired cannot be trusted.
  • They all have an IsDesignMode property, which is similar to DesignMode, but works correctly in all cases, even in the constructor and in virtual methods called from the constructor.
  • BaseControl provides an event for horizontal scrolling, which is not available in the standard Control class.
  • BaseForm and BaseUserControl have a DynamicStringLocalization property that allows enabling simple localization of the controls' localizable string properties directly from .resx files. Localizations for non-existing translations can be automatically generated, and changes can be applied at runtime without restarting the application.
  • BaseForm provides several events and overridable methods to support per-monitor DPI awareness for all target platforms, including .NET Framework 3.5 and 4.x. These can be useful even if you target newer platforms where the standard Form class already supports per-monitor DPI awareness, because the standard implementation has some issues, especially when the application has older awareness settings.

Editing self resources in the KGySoft.WinForms.Example application
Editing newly generated resources for a new language in the KGySoft.WinForms.Example application

AdvancedButton

AdvancedButton supports the following additional features compared to the standard Button control:

  • Adjustable disabled colors
  • Buffered fading animations for any FlatStyle (only for Windows Vista and later when visual styles are enabled)
  • Elevated mode (system shield icon)
  • Consistent font scaling on all platforms when per-monitor DPI awareness is enabled
  • Small visual enhancements, especially in high contrast mode
  • Different text rendering quality options

AdvancedButton in the KGySoft.WinForms.Example application
AdvancedButton in the KGySoft.WinForms.Example application

AdvancedCheckBox/AdvancedRadioButton

AdvancedCheckBox and AdvancedRadioButton support the following additional features compared to the standard CheckBox/RadioButton controls:

  • Adjustable disabled colors
  • Fixed AutoSize behavior when the control is docked (see also AdvancedLabel)
  • Buffered fading animations for any FlatStyle (only for Windows Vista and later when visual styles are enabled)
  • Consistent font scaling on all platforms when per-monitor DPI awareness is enabled
  • Visual enhancements, especially in high contrast mode and with high DPI
  • Different text and visual rendering quality options

AdvancedRadioButton in the KGySoft.WinForms.Example application
RadioButton vs. AdvancedRadioButton> on Windows 11 with high DPI (150%), targeting .NET 9.0

AdvancedComboBox

AdvancedComboBox supports the following most notable additional features compared to the standard ComboBox control:

  • Adjustable disabled colors
  • Read-only mode (similarly to a TextBox)
  • Consistent font scaling on all platforms when per-monitor DPI awareness is enabled
  • Other minor enhancements and fixes

AdvancedComboBox in the KGySoft.WinForms.Example application
AdvancedComboBox in the KGySoft.WinForms.Example application

AdvancedDateTimePicker

Regular DateTimePicker control does not allow custom colors, it does not even have publicly browsable BackColor and ForeColor properties. AdvancedDateTimePicker addresses this issue, allowing even custom disabled colors. When visual styles are enabled and the control is in focus, it switches back to the default rendering. Additionally, it fixes a sort of rendering issues, especially in high DPI scenarios.

AdvancedDateTimePicker in the KGySoft.WinForms.Example application
DateTimePicker vs. AdvancedDateTimePicker> on Windows 11 with high DPI (125%), targeting .NET 9.0

AdvancedLabel

AdvancedLabel supports the following additional features compared to the standard Label/LinkLabel controls:

  • Adjustable disabled colors
  • Fixed AutoSize behavior when the control is docked
  • Buffered fading animations (only for Windows Vista and later when visual styles are enabled). By default, affects toggling the Enabled state only, but can be applied to any visual change.
  • Consistent font scaling on all platforms when per-monitor DPI awareness is enabled
  • Different text and visual rendering quality options
  • Auto hyperlink recognition in text (when allowed)
  • Visual enhancements, such as richer BorderStyle options or fixed hand cursor for hyperlinks

AdvancedLabel in the KGySoft.WinForms.Example application
Some Label vs. AdvancedLabel differences

AdvancedPanel

Just a Panel, whose BorderStyle has a wider range of options than the standard Panel control. See the AdvancedLabel for a visual comparison that has the same variety of border styles.

AdvancedProgressBar

AdvancedProgressBar supports four different styles, including the system default style. Additionally, it supports paused and error states, as well as custom coloring for non-system styles. When visual styles are not available, every style is rendered with the classic appearance.

AdvancedProgressBar in the KGySoft.WinForms.Example application
The various styles of AdvancedProgressBar

AdvancedTextBox/DecimalTextBox

Just like other advanced controls, AdvancedTextBox supports adjustable disabled colors and consistent font scaling on all platforms when per-monitor DPI awareness is enabled. Additionally, it fixes some minor issues regarding corrupted fonts, AcceptsTab and AcceptsReturn handling in read-only mode, or fixing Ctrl+A (select all) behavior when auto appending is enabled.

DecimalTextBox is a specialized version of AdvancedTextBox that can be used as a numeric input control. A fixed number of fractional digits can be specified, which can be even negative, allowing rounding to whole values. When entering a value, you can use multiplier keys t, m, y for thousand, million, and billion (yard) multipliers, respectively. For example, entering 1.5m will result in 1,500,000.

New Control Types

ImageViewer

The ImageViewer control is like a PictureBox, but it supports free zooming and panning. It can toggle smoothing, which can be used even for metafiles to apply antialiasing.

ImageViewer in the KGySoft.WinForms.Example application
The ImageViewer control in the KGySoft.WinForms.Example application

CheckGroupBox

The CheckGroupBox control is a specialized GroupBox that has a check box in the header. It can be used to toggle the enabled state of the controls in the group box.

CheckGroupBox in the KGySoft.Drawing.ImagingTools application
The CheckGroupBox can be used to toggle the enabled status of every control in the group box

CommandLinkButton

A command link is a special button that can be used used to present a choice of action to the user. It is practically a Button, but it has a larger size, and it can display an icon and a description text below the main text. The CommandLinkButton control is a specialized button that supports this functionality.

When FlatStyle is set to System, the control is rendered by the system on Windows Vista and later, when visual styles are enabled. Otherwise, a compatible rendering is used. The actual appearance can be quite different on different Windows versions, with or without visual styles and with high contrast mode enabled.

In most cases, the CommandLinkButton control is used in a task dialog, which is a specialized dialog that can display command links. But if you need to use a custom dialog with commands links that cannot be achieved by task dialogs, you can use the CommandLinkButton control directly.

CommandLinkButtons in the KGySoft.WinForms.Example application
CommandLinkButton controls in the KGySoft.WinForms.Example application on Windows 11, with visual styles enabled

Advanced Dialogs

Task Dialogs

A task dialogs are specialized dialogs that can be used to present elaborate information to the user, and can offer possible actions in different ways. A task dialog can display a title, a main instruction, a message, a concealable detailed description, footer text, and can have command links, radio buttons, a check box and buttons. It can also display icons (a main icon and a footer icon), a progress bar, and supports using a timer. The task dialog is a native Windows component on Windows Vista and later, but the KGy SOFT TaskDialog supports compatibility mode on earlier Windows versions or when visual styles are not enabled.

A native TaskDialog in the KGySoft.WinForms.Example application
A TaskDialog in the KGySoft.WinForms.Example application on Windows 11 with visual styles using native rendering.

⚠️ Warning

.NET 5 also introduced task dialogs, so when targeting .NET 5 or later, referencing the KGy SOFT version requires using aliases or fully qualified type names. You might want to use the KGy SOFT's TaskDialog even when targeting .NET 5 or later for the additional features available in compatible mode only, such as the custom icons for the command links and buttons, tool tips for buttons and radio buttons, fixed rendering in high-contrast mode, richer result when copying the dialog content to the clipboard, and more.

A TaskDialog in the KGySoft.WinForms.Example application using compatible rendering on Windows XP
The same dialog as above, using compatible rendering on Windows XP.

By default, the task dialog uses the native Windows component when available, and switches to compatible rendering otherwise, or when the configuration of your TaskDialog uses some compatible-mode-only features (e.g. button icons or localization of standard buttons). You can also force compatible mode by setting the TaskDialog.ForceCompatibilityMode property to true, which unlocks some additional improvements (e.g. tool tips, rendering fixes, better RTL mode support, richer clipboard content, etc.).

A TaskDialog with custom icons in the KGySoft.WinForms.Example application using compatible rendering on Windows 11
Compatibility mode allows some non-native features like custom command link icons.

Message Dialogs

The static Dialogs class provides several static methods to display message dialogs of information, warning, error and confirmation messages. By default, these methods use the standard MessageBox.Show method internally, but you can opt-in to use the KGy SOFT TaskDialog instead by setting the Dialogs.UseTaskDialogs property to true. Using task dialogs instead of message boxes can be beneficial when the application has per-monitor DPI awareness enabled, because the standard message box is adjusted to the DPI of the primary display in the moment of starting the application, and it may not scale correctly on other displays or when the DPI changes later.

Dialogs.InfoMessage message when it just uses MessageBox
Dialogs.InfoMessage example with the default behavior when it just uses MessageBox.Show.

Input Dialog

The static Dialogs class has various InputDialog overloads that can be used to display a dialog for entering a single line of text. A caption and an optional prompt text can be specified along with a default value, which is pre-selected in the input field.

Dialogs.InputDialog example
Dialogs.InputDialog example on Windows 11.

License

KGy SOFT Core Libraries are under the KGy SOFT License 1.0, which is a permissive GPL-like license. It allows you to copy and redistribute the material in any medium or format for any purpose, even commercially. The only thing is not allowed is to distribute a modified material as yours: though you are free to change and re-use anything, do that by giving appropriate credit. See the LICENSE file for details.


See the complete KGy SOFT Core Libraries documentation with even more examples at docs.kgysoft.net.

KGy SOFT .net

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages