TileViewOptionsHtmlTemplate.AllowContentSelection Property
Gets or sets whether users can select the contents of HTML tags.
Namespace: DevExpress.XtraGrid.Views.Tile
Assembly: DevExpress.XtraGrid.v24.1.dll
NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation
Declaration
[DefaultValue(DefaultBoolean.Default)]
[XtraSerializableProperty]
public DefaultBoolean AllowContentSelection { get; set; }
Property Value
Type | Default | Description |
---|---|---|
DefaultBoolean | Default | Specifies the initial value of the |
Available values:
Name | Description | Return Value |
---|---|---|
True | The value is true. |
|
False | The value is false. |
|
Default | The value is specified by a global option or a higher-level object. |
|
Property Paths
You can access this nested property as listed below:
Object Type | Path to AllowContentSelection |
---|---|
TileView |
|
Remarks
Enable the AllowContentSelection
property to allow users to select text displayed by HTML templates. Note that 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.
The textual content of the selected region is stored in the SelectedHtmlText property. The code below copies this property’s value to the clipboard when a user presses Ctrl+C:
private void OnKeyDown(object sender, KeyEventArgs e) {
TileView tView = sender as TileView;
if (e.Control && e.KeyCode == Keys.C)
Clipboard.SetText(tView.SelectedHtmlText);
}
When the selection changes, the TileView.SelectedHtmlTextChanged event occurs. Handle this event to inspect and modify the SelectedHtmlText property value. For instance, you can cleanse it from the contents of non-textual elements that were selected along with regular text.
private void OnSelectedHtmlTextChanged(object sender, EventArgs e) {
TileView tView = sender as TileView;
string updatedText = tView.SelectedHtmlText.Replace(" OK Cancel ", " ");
}
You can also use the user-select
CSS property to prevent unwanted HTML elements from being selected when the AllowContentSelection property is enabled.
<div class="button unselectable">Cancel</div>
.unselectable { user-select: none; }
If the AllowContentSelection property is set to DefaultBoolean.Default
or DefaultBoolean.False
, utilize the user-select
CSS property to enable selection for individual elements.
.selectable { user-select: all; }
.selectableText { user-select: text; }