Back to Devexpress

RepositoryItemPictureEdit.SizeMode Property

windowsforms-devexpress-dot-xtraeditors-dot-repository-dot-repositoryitempictureedit-d7582c93.md

latest8.0 KB
Original Source

RepositoryItemPictureEdit.SizeMode Property

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

Namespace : DevExpress.XtraEditors.Repository

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DXCategory("Behavior")]
public virtual PictureSizeMode SizeMode { get; set; }
vb
<DXCategory("Behavior")>
Public Overridable Property SizeMode As PictureSizeMode

Property Value

TypeDescription
PictureSizeMode

The displayed image’s size mode.

|

Available values:

NameDescription
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.

csharp
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;
}
vb
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)

AddHandler comboBoxEdit1.SelectedIndexChanged, AddressOf ComboBoxEdit1_SelectedIndexChanged

private void ComboBoxEdit1_SelectedIndexChanged(Object sender, EventArgs e)
    Dim control As ComboBoxEdit = TryCast(sender, ComboBoxEdit)
    pictureEdit1.Properties.SizeMode = CType(control.SelectedItem, PictureSizeMode)

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.

winforms-pictureedit-drag-images-from-windows-explorer/CS/WindowsApplication3/DragDropProvider.cs#L20

csharp
this.edit = edit;
    edit.Properties.SizeMode = DevExpress.XtraEditors.Controls.PictureSizeMode.Squeeze;
}

winforms-tab-control-custom-header-buttons/CS/XtraTabControl_CustomButtons/Form1.cs#L57

csharp
picEdit.Properties.PictureAlignment = ContentAlignment.MiddleCenter;
picEdit.Properties.SizeMode = PictureSizeMode.Squeeze;
picEdit.Parent = page;

winforms-grid-display-icons-in-data-cells/VB/Form1.vb#L176

vb
Dim pictureEdit As RepositoryItemPictureEdit = TryCast(gridControl1.RepositoryItems.Add("PictureEdit"), RepositoryItemPictureEdit)
pictureEdit.SizeMode = PictureSizeMode.Zoom
pictureEdit.NullText = " "

winforms-pictureedit-drag-images-from-windows-explorer/VB/WindowsApplication3/DragDropProvider.vb#L18

vb
Me.edit = edit
    edit.Properties.SizeMode = DevExpress.XtraEditors.Controls.PictureSizeMode.Squeeze
End Sub

winforms-grid-visualize-master-detail-data/VB/Form1.vb#L47

vb
'Stretch images within cells.
riPictureEdit.SizeMode = DevExpress.XtraEditors.Controls.PictureSizeMode.Stretch
gridView1.Columns("Picture").OptionsColumn.FixedWidth = True

winforms-tab-control-custom-header-buttons/VB/XtraTabControl_CustomButtons/Form1.vb#L63

vb
picEdit.Properties.PictureAlignment = ContentAlignment.MiddleCenter
picEdit.Properties.SizeMode = PictureSizeMode.Squeeze
picEdit.Parent = page

See Also

Image

SvgImage

PictureAlignment

PictureInterpolationMode

RepositoryItemPictureEdit Class

RepositoryItemPictureEdit Members

DevExpress.XtraEditors.Repository Namespace