Skip to main content
All docs
V24.1

TreeListOptionsHtmlTemplate.AllowContentSelection Property

Gets or sets whether users can select the contents of HTML tags.

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v24.1.dll

NuGet Packages: DevExpress.Win.Navigation, DevExpress.Win.TreeList

Declaration

[DefaultValue(DefaultBoolean.Default)]
[XtraSerializableProperty]
public DefaultBoolean AllowContentSelection { get; set; }

Property Value

Type Default Description
DefaultBoolean Default

Specifies the initial value of the user-select CSS property for all HTML elements. The DefaultBoolean.True value sets this property to auto, the DefaultBoolean.False and DefaultBoolean.Default values set it to none.

Available values:

Name Description Return Value
True

The value is true.

0

False

The value is false.

1

Default

The value is specified by a global option or a higher-level object.

2

Property Paths

You can access this nested property as listed below:

Object Type Path to AllowContentSelection
TreeList
.OptionsHtmlTemplate .AllowContentSelection

Remarks

Enable the AllowContentSelection property to allow users to select text displayed by HTML templates. When users drag the mouse pointer to select a portion of text – button captions, images, and other HTML elements along the way are also selected.

HTML Template Content Selection - WinForms TreeList

The following example copies text content of selected HTML elements to the clipboard when a user presses Ctrl+C:

using DevExpress.XtraTreeList;

private void treeList1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) {
    if(e.Control && e.KeyCode ==System.Windows.Forms.Keys.C) {
        System.Windows.Clipboard.SetText((sender as TreeList).SelectedHtmlText);
    }
}

You can also use the user-select CSS property to prevent unwanted HTML elements from being selected when the AllowContentSelection property is enabled.

.unselectable { user-select: none; }

If the AllowContentSelection property is set to DefaultBoolean.Default or DefaultBoolean.False, use the user-select CSS property to enable selection for individual HTML elements.

.selectable { user-select: all; }
.selectableText { user-select: text; }
See Also