Skip to main content

Application Switches

WATCH & LEARN0:49 · Animated tutorial
7 scenesPlay, pause, or scrub at your own pace
Since 3.5.6

Some default behaviors in Wisej.NET are configurable with AppContext switches. These are the switches currently supported:

Label Self Size​

LabelSelfSize (default: true)

The AutoSize behavior of Label differs from that of other controls, especially in standard containers such as Panel, Form, Page, and GroupBox. When a Label is anchored to the right in one of these containers, AutoSize adjusts its width while keeping its left edge in place. The right edge moves as the label grows or shrinks.

When the Label is in a custom layout container (FlexLayoutPanel, FlowLayoutPanel, TableLayoutPanel), AutoSize behaves like other controls.

Corresponds to Label.SelfSizeDefault and Label.SelfSize.

DataGridView Auto Select​

DataGridViewAutoSelectFirstRow (default: true)

By default, setting the current cell in a DataGridView selects the row, cell, or column based on SelectionMode. To prevent automatic selection when setting the current cell, set DataGridViewAutoSelectFirstRow to false.

Corresponds to DataGridView.AutoSelectFirstRowDefault and DataGridView.AutoSelectFirstRow.

DataGridView Auto Generate​

DataGridViewAutoGenerateColumns (default: true)

The DataGridView automatically generates columns when DataSource is assigned in the designer, then sets AutoGenerateColumns to false after creating and serializing columns. Setting DataSource to null resets AutoGenerateColumns to true.

You cannot set AutoGenerateColumns directly in the designer because the designer manages it through DataSource. To change its initial default to false, use the DataGridViewAutoGenerateColumns switch.

Corresponds to DataGridView.AutoGenerateColumnsDefault.

Form Auto Close​

FormAutoCloseModalDialog (default: false)

By default, you must call Close() to close a Wisej.NET modal dialog. Set AutoCloseModalDialog to true to close the dialog automatically when Form.DialogResult is assigned a value other than DialogResult.None.

When AutoCloseModalDialog is true, the dialog closes automatically when:

  • User clicks AcceptButton or CancelButton with DialogResult set
  • Code sets the DialogResult property

This matches WinForms behavior but differs from Wisej.NET's default.

Corresponds to Form.AutoCloseModalDialogDefault and Form.AutoCloseModalDialog.

Setting AppContext Switches​

See Microsoft's System.AppContext documentation for various configuration approaches. Example code setup:

// Program static contstructor
public static class Program {

public void static Program() {
AppContext.SetSwitch("LabelSelfSize", false);
}
}