vcl-cxdbedit-acd61e44.md
A data-aware image editor.
TcxDBImage = class(
TcxCustomImage
)
The TcxDBImage control displays and manages an image stored in a database. Context menu items include clipboard operations, open/save file commands, and a shortcut to the Image Editor dialog.
Tip
You can use the Properties.PopupMenuLayout.MenuItems property to customize the list of context menu items.
Image editors can use different TGraphic class descendants as image containers. You can use the Properties.GraphicClass property to switch between image container types.
BMP | EMF | GIF | JPEG | PNG | TIFF | WMFSupport for these image formats relies on corresponding native encoders from the Windows Imaging Component (WIC).SVGDevExpress controls use our own SVG engine implementation. Refer to the following topic for detailed information on supported SVG elements and their attributes: SVG Image Support.
Tip
We recommend that you set the Properties.GraphicClass property to TdxSmartImage to ensure that the TcxDBImage editor supports all of these formats.
Image editors can display a modal Image Editor dialog that allows users to perform simple image edit operations, such as cropping, rotation, and color adjustment.
A user can click the Edit… item in the image editor’s context menu to display the Image Editor dialog.
Refer to the TcxPopupMenuLayout.MenuItems property description for detailed information on menu item management and a code example.
The list below outlines key members of the TcxDBImage class that allow you to load and save images as well as configure image editor settings.
ParentColorSpecifies if the image editor uses its parent color to fill the background area when no image is displayed.Style | StyleDisabled | StyleFocused | StyleHot | StyleReadOnly
Allow you to define individual appearance settings for different editor states.
Tip
To apply the same style settings to multiple editors, use a TcxEditStyleController component. If you need to apply the same style settings to all editors in your application, you can use a TcxDefaultEditStyleController component.
StylesProvides access to individual styles applied to the image editor in different states.TransparentSpecifies if the image editor is transparent in GDI render mode.
AnimationOptionsProvides access to GIF animation settings.ClipboardFormatSpecifies the active clipboard image format.CopyToClipboard | CutToClipboard | PasteFromClipboardAllow you to perform clipboard operations.DataBindingAllows you to bind the image editor to data.LoadFromFileDisplays the Open dialog that allows users to load a supported image file.PictureProvides access to the editor’s image container and allows you to configure its settings.SaveToFileOpens the Save As dialog that allows users to save the displayed image to a file.ShowImageEditorDisplays the modal Image Editor dialog that allows users to perform simple image edit operations.ZoomingOptions
Allows you to zoom the displayed image in or out and customize zoom-related settings.
Note
Zoom operations are available only if the Properties.FitMode property is set to ifmNormal.
ActivePropertiesProvides access to the current image editor settings regardless of their source. This property set does not allow you to customize image editor settings.GetPropertiesClassReturns the actual editor settings type.PropertiesAllows you to customize image editor settings directly if the editor does not have an assigned repository item.RepositoryItemSpecifies a repository item as an external source of editor settings. A repository item has priority over other editor settings.
AutoSizeSpecifies if the image editor automatically adjusts its size to fit the displayed image.EnabledSpecifies if the image editor is enabled.ShowHintSpecifies if the image editor can display hints.Width | HeightAllow you to explicitly define image editor dimensions when the AutoSize property is set to False ( default ).
The following code example creates a BLOB field in a TdxMemData component and binds a TcxDBImage editor to the field:
uses
dxGDIPlusClasses; // Declares the TdxSmartImage class
// ...
var
AFieldDef: TFieldDef;
begin
if dxMemData1.Active then
dxMemData1.Close;
AFieldDef := dxMemData1.FieldDefs.AddFieldDef;
AFieldDef.Name := 'MyImageField';
AFieldDef.DataType := ftBlob;
AFieldDef.CreateField(dxMemData1);
DataSource1.DataSet := dxMemData1;
DataSource1.Enabled := True;
cxDBImage1.DataBinding.DataSource := DataSource1;
cxDBImage1.DataBinding.DataField := 'MyImageField';
cxDBImage1.Properties.GraphicClass := TdxSmartImage; // Selects the universal container
dxMemData1.Open;
end;
#include "dxGDIPlusClasses.hpp" // Declares the TdxSmartImage class
// ...
TFieldDef *AFieldDef;
// ...
if(dxMemData1->Active) { dxMemData1->Close(); }
AFieldDef = dxMemData1->FieldDefs->AddFieldDef();
AFieldDef->Name = "MyImageField";
AFieldDef->DataType = ftBlob;
AFieldDef->CreateField(dxMemData1);
DataSource1->DataSet = dxMemData1;
DataSource1->Enabled = true;
cxDBImage1->DataBinding->DataSource = DataSource1;
cxDBImage1->DataBinding->DataField = "MyImageField";
cxDBImage1->Properties->GraphicClass = __classid(TdxSmartImage); // Selects the universal container
dxMemData1->Open();
The following code example allows users to select and load an image file to the bound BLOB dataset field in a TdxMemData component:
var
ADataBinding: TcxDBEditDataBinding;
AField: TBlobField;
begin
ADataBinding := cxDBImage1.DataBinding;
dxOpenPictureDialog1.Execute(Handle);
if ((dxOpenPictureDialog1.FileName = '') or (not ADataBinding.CanModify)) then Exit;
dxMemData1.DisableControls;
try
dxMemData1.Append;
AField := ADataBinding.Field as TBlobField;
AField.LoadFromFile(dxOpenPictureDialog1.FileName);
dxMemData1.Post;
finally
dxMemData1.EnableControls;
end;
end;
TcxDBEditDataBinding *ADataBinding;
TBlobField *AField;
// ...
ADataBinding = cxDBImage1->DataBinding;
dxOpenPictureDialog1->Execute(Handle);
if((dxOpenPictureDialog1->FileName == "") || (!ADataBinding->CanModify())) { return; }
dxMemData1->DisableControls();
try
{
dxMemData1->Append();
AField = dynamic_cast<TBlobField*>(ADataBinding->Field);
AField->LoadFromFile(dxOpenPictureDialog1->FileName);
dxMemData1->Post();
}
__finally
{
dxMemData1->EnableControls();
}
You can create a TcxEditRepositoryImageItem component in an edit repository to store image editor settings and share them between multiple image editors.
Show 13 items
TObject TPersistent TComponent TControl TWinControl TCustomControl TcxCustomControl TcxControl TcxContainer TcxCustomEditContainer TcxCustomEdit TcxCustomImage TcxDBImage
See Also