BLOB Editors
- 3 minutes to read
BLOB Editors
Common examples of BLOB (Binary Large OBject) data are large text blocks (called memo data), images, sounds, etc. Generally speaking, BLOB is a sequence of uninterpreted bytes. The consumer is responsible for interpreting the contents of a BLOB.
The XtraEditors library provides two editors for presenting and editing BLOB data: ImageEdit and MemoExEdit. These editors are designed to display images and large text data within dropdown windows. Rather than use dropdowns though, you may prefer to display image/text directly within a control’s client area by using the PictureEdit and MemoEdit controls instead.
ImageEdit
The ImageEdit and PictureEdit editors enables you to display images stored in any format supported by .NET (BMP, GIF, JPEG, TIFF, WMF, etc). You can bind an image editor to a data source field that contains graphic information in one of these formats. Note: image editors can only be bound to data fields via code. See the Data Binding Overview document for more information.
The image editor’s repository item object (RepositoryItemImageEdit) provides many properties and events to customize the editor. For instance, the RepositoryItemImageEdit.ShowMenu property defines whether the built-in image editing context menu is available to end-users.
The RepositoryItemImageEdit.SizeMode property controls how the image should fit the dropdown window (whether the image is stretched or clipped).
MemoExEdit
The MemoExEdit control is similar to the MemoEdit. Both editors allow the display and editing of large text blocks displayed in multiple lines.
The editor’s repository item is represented by the RepositoryItemMemoExEdit class providing editor-specific settings. For instance, the RepositoryItemMemoExEdit.AcceptsReturn and RepositoryItemMemoExEdit.AcceptsTab properties specify whether end-users are allowed to enter carriage returns and tabs using the ENTER and TAB keys. The RepositoryItemMemoExEdit.WordWrap property specifies whether the word wrapping feature is enabled. To specify scroll bar availability, use the RepositoryItemMemoExEdit.ScrollBars property.
Common Properties of BLOB Editors
The ImageEdit and MemoExEdit editors are derived from the same base class (BlobBaseEdit). Their repository items also have the same ancestor (RepositoryItemBlobBaseEdit). These base classes declare settings common to BLOB editors. This section briefly describes these settings.
By default, ImageEdit and MemoExEdit edit boxes display predefined icons to indicate whether the editor contains data.
ImageEdit | MemoExEdit | |
---|---|---|
The editor contains data | ||
The editor does not contain data |
You can use the RepositoryItemBlobBaseEdit.Images property to provide custom icons to represent these empty and filled states. To do this, create an ImageCollection/ImageList component and add two icons to it. The first icon should correspond to the filled state. Finally, assign the ImageCollection/ImageList to the RepositoryItemBlobBaseEdit.Images property.
Example
The sample code below shows how to supply custom icons for an ImageEdit control.
//Create ImageList and add two images
ImageList list = new ImageList();
list.Images.Add(Image.FromFile("Image.bmp"));
list.Images.Add(Image.FromFile("ImageEmpty.bmp"));
//Supply the image list
imageEdit1.Properties.Images = list;
Icons are used only when the RepositoryItemBlobBaseEdit.ShowIcon property is set to true. If this property value is false, empty MemoExEdit editors display an empty edit box. If the editor contains text, the edit box will display its first line. ImageEdit editors display the “(Picture)” and “(Empty)” strings as appropriate.
ImageEdit | MemoExEdit | |
---|---|---|
The editor contains data | ||
The editor does not contain data |
Use the RepositoryItemBlobBaseEdit.PopupSizeable property to specify whether end-users are allowed to resize the popup window. When the property is enabled, the dropdown window will display a resize grip. Resizing the window not only changes its size but also provides its size when re-opened. The window’s initial size can be defined via the RepositoryItemBlobBaseEdit.PopupStartSize property.