Application Switches

Since 3.5.6

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

LabelSelfSize (default: true)

The behavior of auto sizing in Label controls exhibits a unique characteristic compared to other controls, especially when contained within standard containers like Panels, Forms, Pages, or GroupBoxes. When a Label is anchored to the right within these containers, its auto sizing functionality adjusts the Label's width while consistently maintaining its left-most position. This ensures that as the Label grows or shrinks, it does so by expanding or contracting towards the right side, without altering its starting position on the left.

When the label is a child of a container with a custom (i.e. FlexLayoutPanel, FlowLayoutPanel, TableLayoutPanel) the auto sizing behavior is the same as all other controls.

Corresponds to Label.SelfSizeDefault and Label.SelfSize.

DataGridViewAutoSelectFirstRow (default: true)

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

Corresponds to DataGridView.AutoSelectFirstRowDefault and DataGridView.AutoSelectFirstRow.

DataGridViewAutoGenerateColumns (default: true)

The DataGridView is set to automatically generate new columns when the DataSource is assigned in the designer and to set the property AutoGeneateColumns to false after the columns are created and serialized. Setting the DataSource to null in the designer will reset the value of AutoGeneateColumns to true.

It is not possible to set the property AutoGeneateColumns using the designee because it is managed in conjunction with the DataSource property. You can, however, initialize it to false as the default initial value by setting the "DataGridViewAutoGenerateColumns" application switch to false.

Corresponds to DataGridView.AutoGenerateColumnsDefault.

FormAutoCloseModalDialog (default: false)

To close a modal dialog in Wisej.NET you must call the Close() method in all cases. However, setting the property AutoCloseModalDialog to true, will automatically close a modal dialog when assigning the Form.DialogResult property to any value other than DialogResult.None.

When AutoCloseModalDialog is true, and the user clicks the AcceptButton or CancelButton (if they have their DialogResult property assigned), or the code sets the DialogResult property, Wisej.NET automatically closes the dialog. This is the default behavior in WinForms, which is different from the default behavior in Wisej.NET.

Corresponds to Form.AutoCloseModalDialogDefault and Form.AutoCloseModalDialog.

How to Set AppContext Switches

See Microsoft's documentation about System.AppContext to lear how to set the context switches using different approaches. To set a switch in code, see the example below.

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

Last updated