MyCol := TcxColumn.Create;
... MyCol.PropertiesClass := TcxImageProperties;
ImageProps := TcxImageProperties(MyCol.Properties);
ImageProps.Center := True;
ImageProps.GraphicClassName := '';
ImageProps.OnGetGraphicClass := GetThumbnailGraphicClass;
ImageProps.Stretch := True;
... Procedure GetThumbnailGraphicClass: procedure TCORSA.GetThumbnailGraphicClass(AItem: TObject;
ARecordIndex: Integer; APastingFromClipboard: Boolean;
var AGraphicClass: TGraphicClass);
begin
if AnsiSAmeText(FThumbNailExtension, '.TIF') then
AGraphicClass := TGraphicClass(GetClass('TTiffGraphic'))
else
if AnsiSAmeText(FThumbNailExtension, '.JPG') then
AGraphicClass := TGraphicClass(GetClass('TJPEGImage'))
end; The actual thumbnail data is loaded into the grid via streams: MStream := TMemoryStream.Create;
Stream := TStringStream.Create(''); MStream.LoadFromFile(ThumbNail);
Stream.CopyFrom(MStream, MStream.Size); FActiveGrid.DataController.SetValue(RowInfo.RecordIndex,
ThumbCol,
Stream.DataString);

改进后的:

 

function StreamToVar(Stream: TStream): OleVariant;
var
P: Pointer;
begin
Result := VarArrayCreate([, Stream.size -],Varbyte);
P := VarArrayLock(Result);
Try
Stream.Position := ;
Stream.Read(P^, Stream.size);
Finally
VarArrayUnlock(Result);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
IRecIdx : Integer;
stream : TMemoryStream;
begin
with cxGrid1TableView1.DataController do
begin
IRecIdx := AppendRecord;
stream := TMemoryStream.Create();
stream.LoadFromFile('H:\pic\随拍\IMAG0002.jpg');
stream.Position := ;
Values[IRecIdx,] := StreamToVar(stream);
stream.Free;
Post;
end;
end;

TcxGrid Column动态添加Image的更多相关文章

  1. 编辑 Ext 表格(一)——— 动态添加删除行列

    一.动态增删行 在 ext 表格中,动态添加行主要和表格绑定的 store 有关, 通过对 store 数据集进行添加或删除,就能实现表格行的动态添加删除.   (1) 动态添加表格的行  gridS ...

  2. Android开发之动态添加控件

    动态添加TextView控件: 一:创建一个Android project项目 activity_main.xml文件: 1.用两个LinearLayout布局分别包裹一对TextView,EditT ...

  3. C# DataGridView控件动态添加新行

    C# DataGridView控件动态添加新行 DataGridView控件在实际应用中非常实用,特别需要表格显示数据时.可以静态绑定数据源,这样就自动为DataGridView控件添加相应的行.假如 ...

  4. WPF实现选项卡效果(3)——自定义动态添加的AvalonDock选项卡内容

    原文:WPF实现选项卡效果(3)--自定义动态添加的AvalonDock选项卡内容 简介 在前面一篇文章里面,我们实现了AvalonDock选项卡的动态添加,但是对于选项卡里面的内容,我们并没有实现任 ...

  5. 关于devexpress报表XtraReport,动态修改报表样式(.repx格式),动态添加数据并使用的理解

    一.基本概念: XtraReports 中的每个报表都由 XtraRepot 类的一个实例表示,或者由该类的子类来表示(这种情况更常见). 因此,每个报表都作为带区的容器使用,而每个带区中都包含报表控 ...

  6. 利用cglib给javabean动态添加属性,不用在建VO

    有的时候 比如你用的是hibernate或者Spring jdbc 来做dao层进行数据库相关的操作的时候,若果是单表的操作的时候 还比较简单 hibernate可直接返回(get,load)你的需要 ...

  7. WPF GridView动态添加项并读取数据

    假设数据库有如下表, 首先我们创建一个WPF工程,界面如下 <Window x:Class="WpfApplication2.MainWindow" xmlns=" ...

  8. WPF中TreeView控件数据绑定和后台动态添加数据(一)

    数据绑定: 更新内容:补充在MVVM模式上的TreeView控件数据绑定的代码. xaml代码: <TreeView Name="syntaxTree" ItemsSourc ...

  9. js动态添加事件-事件委托

    作者:白狼 出处:http://www.manks.top/javascript-dynamic-event.html 本文版权归作者,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给 ...

随机推荐

  1. 如何在virtualenv环境中安装指定的python版本

    指定python版本:virtualenv   -p python执行文件路径     自定义虚拟环境名称.如果文件路径有空格,用引号. 如果不指定python版本,则默认使用环境变量中的python ...

  2. WSGI服务与django的关系

    WSGI接口 wsgi是将python服务器程序连接到web服务器的通用协议.uwsgi是独立的实现了wsgi协议的服务器.   web服务器 服务端程序 简化版的WSGI架构 服务端程序(类似dja ...

  3. FIS 雪碧图sprite合并

    1 安装fis(必须先安装node和npm):npm install -g fis3 2 构建项目发布到根目录下的output:fis3 release -d ./output 项目根目录:FIS3 ...

  4. 洛谷【P3407】散步

    我对状态空间的理解:https://www.cnblogs.com/AKMer/p/9622590.html 题目传送门:https://www.luogu.org/problemnew/show/P ...

  5. Java访问子类对象的实例变量

    对于Java这种语言来说,一般来说,子类可以调用父类中的非private变量,但在一些特殊情况下, Java语言可以通过父类调用子类的变量 具体的还是请按下面的例子吧! package com.yon ...

  6. Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: Cannot open connection

    Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceE ...

  7. DES加密/解密

    /// <summary> /// DES加密/解密类. /// </summary> public class DESEncrypt { #region ========加密 ...

  8. Eclipse中插件的使用:maven /ant /tomcat

    一:使用Eclipse构建Maven项目 http://blog.csdn.net/jackgaolei/article/details/11332249 二:Maven介绍,包括作用.核心概念.用法 ...

  9. macOS 安装 Docker

    系统要求 Docker for Mac 要求系统最低为 macOS 10.10.3 Yosemite,或者 2010 年以后的 Mac 机型,准确说是带 Intel MMU 虚拟化的,最低 4GB 内 ...

  10. Windows命令快捷打开

    Win+R或者在搜索中输入: control -- 控制面板 mstsc -- 远程连接 SnippingTool -- 截图工具