Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions knowledge-base/fix-winforms-runtime-dpi-aware-application.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
title: Resolving Unexpected Per-Monitor DPI Awareness in WinForms Apps
description: Fix a WinForms application that unexpectedly becomes (per‑monitor) DPI aware and changes size when using controls depending on the Telerik Document Processing libraries.
type: how-to
page_title: Why Your WinForms App Resizes - DPI Awareness and Telerik Document Processing Explained
slug: fix-winforms-runtime-dpi-aware-application
position: 0
tags: winforms,windows, forms, dpi, scaling, document, processing, pdf, viewer, rich, text, editor, spreadsheet, control, aware, shrink, scale
res_type: kb
---

## Environment

|Product Version|Product|Author|
|----|----|----|
|All|Document Processing Libraries|[Yoan Karamanov](https://www.telerik.com/blogs/author/yoan-karamanov)|

## Description

A WinForms application may appear smaller (or larger) at runtime after using [Document Processing Libraries]({%slug introduction%}) (**DPL**) functionality or [DPL-dependent Telerik controls](https://docs.telerik.com/devtools/winforms/integration-with-other-telerik-products/document-processing-libraries#telerik-ui-for-winforms-integration) (e. g. **RadPdfViewer**, **RadSpreadsheet**). This can occur, for example, when **exporting data**, loading a document, or instantiating types from assemblies used by:

These dependencies internally rely on WPF assemblies where DPI awareness is enabled at the assembly level. The moment a type from such an assembly is initialized, the hosting WinForms process can become DPI-aware.

## Solution

You can choose between two approaches:

### 1. Make the application explicitly DPI-aware

With this approach your app will look smaller when started. It will not look blurry on HDPI displays. Detailed information is available in the [DPI Support](https://docs.telerik.com/devtools/winforms/telerik-presentation-framework/dpi-support) article.

### 2. Keep (or force) the application DPI-unaware (Windows 10 only)

This approach works only on Windows 10. If you intend to use your application on machines where the DPI scaling is larger than 100 percent, you should explicitly set the application to be DPI-unaware

#### [C#] Force process DPI unaware before using a Document Processing type

```csharp
private void workbookTestButton_Click(object sender, EventArgs e)
{
SetProcessDpiAwareness(_Process_DPI_Awareness.Process_DPI_Unaware);
Workbook wb = new Workbook();
}

[DllImport("shcore.dll")]
static extern int SetProcessDpiAwareness(_Process_DPI_Awareness value);

enum _Process_DPI_Awareness
{
Process_DPI_Unaware = 0,
Process_System_DPI_Aware = 1,
Process_Per_Monitor_DPI_Aware = 2
}
```

>note None of the above approaches affect the application when the scaling is set to 100%.

## See Also

* [DPI Support](https://docs.telerik.com/devtools/winforms/telerik-presentation-framework/dpi-support)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
title: Simulating a Checkbox with Conditional Formatting in Telerik SpreadProcessing
description: Learn how to simulate a checkbox using conditional formatting with Telerik SpreadProcessing.
type: how-to
page_title: Simulating a Checkbox Using Conditional Formatting with Telerik SpreadProcessing
meta_title: Simulating a Checkbox Using Conditional Formatting with Telerik SpreadProcessing
slug: spreadprocessing-simulating-checkbox-conditional-formatting
tags: spread, processing, conditional, formatting, check, box, telerik, document, xlsx
res_type: kb
ticketid: 1667088
---

## Environment

|Product Version|Product|Author|
|----|----|----|
|2025.3.806|[SpreadProcessing]({%slug radspreadprocessing-overview%})|[Yoan Karamanov](https://www.telerik.com/blogs/author/yoan-karamanov)|

## Description

This article describes how to use the [SpreadProcessing]({%slug radspreadprocessing-overview%}) library to simulate a checkbox by using conditional formatting rules. The goal is to display a checked symbol (☑) when the cell value is **1** and an unchecked symbol (☐) when the cell value is **0**.

This knowledge base article also answers the following questions:
- How to simulate checkbox behavior in Telerik SpreadProcessing?
- How to use conditional formatting for representing checkboxes?
- How to display different symbols based on cell values in Telerik SpreadProcessing?

## Solution

To simulate a checkbox using conditional formatting in Telerik SpreadProcessing, apply two separate conditional formatting rules: one for the `checked` state and one for the `unchecked` state.

1. Create a [Workbook]({%slug radspreadprocessing-working-with-workbooks-what-is-workbook%}) and add a worksheet.
2. Define a [DifferentialFormatting]({%slug radspreadprocessing-features-conditional-formatting%}) for the checked state with a format that displays "☑".
3. Create an **EqualToRule** for the checked state, matching cells with a value of **1**.
4. Apply the conditional formatting rule to the cell.
5. Define another **DifferentialFormatting** for the unchecked state with a format that displays "☐".
6. Create an **EqualToRule** for the unchecked state, matching cells with a value of **0**.
7. Apply the second conditional formatting rule to the cell.
8. Set the cell value to **1** or **0** to test the checkbox simulation.
9. Export the workbook to an XLSX file.

![Conditional Formatting CheckBox](images/conditional-formatting-checkbox.png)

Here’s an example implementation:

```csharp
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets.Add();

// Define formatting for checked state
DifferentialFormatting checkedFormatting = new DifferentialFormatting();
checkedFormatting.CellValueFormat = new CellValueFormat("☑");
EqualToRule checkedRule = new EqualToRule("1", checkedFormatting);
ConditionalFormatting checkedConditionalFormatting = new ConditionalFormatting(checkedRule);
worksheet.Cells[0, 0].AddConditionalFormatting(checkedConditionalFormatting);

// Define formatting for unchecked state
DifferentialFormatting uncheckedFormatting = new DifferentialFormatting();
uncheckedFormatting.CellValueFormat = new CellValueFormat("☐");
EqualToRule uncheckedRule = new EqualToRule("0", uncheckedFormatting);
ConditionalFormatting uncheckedConditionalFormatting = new ConditionalFormatting(uncheckedRule);
worksheet.Cells[0, 0].AddConditionalFormatting(uncheckedConditionalFormatting);

// Set initial value to simulate checkbox
worksheet.Cells[0, 0].SetValue(1);

// Export workbook to XLSX file
string xlsxOutputPath = "output.xlsx";
IWorkbookFormatProvider xlsxFormatProvider = new XlsxFormatProvider();

using (Stream output = new FileStream(xlsxOutputPath, FileMode.Create))
{
xlsxFormatProvider.Export(workbook, output, TimeSpan.FromSeconds(10));
}
```

## See Also

* [Conditional Formatting]({%slug radspreadprocessing-features-conditional-formatting%})
* [Workbook]({%slug radspreadprocessing-working-with-workbooks-what-is-workbook%})
* [Using XlsxFormatProvider]({%slug radspreadprocessing-formats-and-conversion-xlsx-xlsxformatprovider%})