Skip to main content
A newer version of this page is available. .

RepositoryItemPictureEdit.SizeMode Property

Gets or sets how the image changes size within the picture editor.

Namespace: DevExpress.XtraEditors.Repository

Assembly: DevExpress.XtraEditors.v18.2.dll

Declaration

[DXCategory("Behavior")]
[SmartTagProperty("Size Mode", "")]
public virtual PictureSizeMode SizeMode { get; set; }

Property Value

Type Description
PictureSizeMode

The displayed image’s size mode.

Available values:

Name Description
Clip

A picture is not stretched.

Stretch

A picture is stretched in order to fit within the area of an editor (or editor’s dropdown window).

Zoom

A picture is stretched proportionally. The picture fits within the area of an editor (or editor’s dropdown window) at least in one direction.

StretchHorizontal

A picture is stretched horizontally. Its height remains unchanged.

StretchVertical

A picture is stretched vertically. Its width remains unchanged.

Squeeze

An image is displayed as is if its actual size is smaller than the size of the container. If the image size is larger than the container’s size, the image is shrunk proportionally to fit the container’s bounds.

Remarks

Use the SizeMode property to control how the image changes its size within the picture editor. The image can appear as is, or it can stretch to fit the editor area, or stretch proportionally.

The effect of the size mode can depend upon the RepositoryItemPictureEdit.PictureAlignment property setting.

When you change the SizeMode value at runtime, the RepositoryItem.PropertiesChanged event occurs.

When users utilize PictureEdit menu to zoom a image (see RepositoryItemPictureEdit.ShowZoomSubMenu), the SizeMode property is automatically set to Clip.

Note

Images (especially bitmap images) may loose quality in stretch modes. Metafiles (lists of graphical instructions for drawing images at run time) are better suited for stretch behavior than bitmaps.

The code sample below illustrates an image’s size modes within a picture edit control.


comboBoxEdit1.Properties.Items.Add(PictureSizeMode.Clip);
comboBoxEdit1.Properties.Items.Add(PictureSizeMode.Squeeze);
comboBoxEdit1.Properties.Items.Add(PictureSizeMode.Stretch);
comboBoxEdit1.Properties.Items.Add(PictureSizeMode.StretchHorizontal);
comboBoxEdit1.Properties.Items.Add(PictureSizeMode.StretchVertical);
comboBoxEdit1.Properties.Items.Add(PictureSizeMode.Zoom);

comboBoxEdit1.SelectedIndexChanged += ComboBoxEdit1_SelectedIndexChanged;

private void ComboBoxEdit1_SelectedIndexChanged(object sender, EventArgs e)
{
    ComboBoxEdit control = sender as ComboBoxEdit;
    pictureEdit1.Properties.SizeMode = (PictureSizeMode)control.SelectedItem;
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the SizeMode property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also