比如该列的值有两情况1和2, 现在要求显示成相应的图形显示,比如值为1的时候显示a.bmp,值为2的时候显示b.bmp,如何设置

解决方案 »

  1.   

    给你找了点资料你看看,有用不?
     
     EhLib使用  
    定制网格标题 
    复杂标题 
    TDBGridEh 允许在多列上创建标题,设置 DBGridEh.UseMultiTitle 属性为 True 并且填充字段的标签或列标题的标题,可以使用下面的规则:字段标签中的文本部分或列标题必须由几部分组成,并且用 "|" 分割,几个列的每一个通用部分都设置为相同。其它字段或标题必须在相应的部分包含同样的文本。 例如:
    Field1.DisplayLabel := 'Title1|SubTitle1';
    Field2.DisplayLabel := 'Title1|SubTitle2';

    DBGridEh.Columns[0].Title.Caption := 'Title1|SubTitle1';
    DBGridEh.Columns[1].Title.Caption := 'Title1|SubTitle2'; 按钮式标题 
    设置Column.Title.TitleButton 为 True可以强制标题单元为按钮式。写 OnTitleBtnClick事件来控制用户单击标题单元时的操作。 在标题中显示位图 
    To show bitmap in titles instead of caption use TitleImages property of TDBGridEh and ImageIndex property of TColumnTitleEh. 自动用位置标识排序标题. 
    TDBGridEh allows to show special sorting bitmaps (small triangles) in the right part of title cell. In order to automatically ing title by sorting bitmaps add dghAutoSortMarking to OptionsEh property. Add dghMultiSortMarking too in order to allow sorting several columns simultaneously. Set Column.Title.TitleButton to true for titles which will have possibility to change sorters at run time. At runtime clicking on title will change sorting. Holding Ctrl key allows to  several columns simultaneously. After user change soring grid call OnSortMarkingChanged event. You can write this event to change sorting and reopen in dataset. Use SortMarkedColumns property to access to sorted columns. 标题属性的默认值 
    使用TDBGridEh.ColumnDefValues.Title来设置标题属性的默认值。 定制网格页脚 
    页脚以及统计值 
    TDBGridEh allows to show special row (footer) or rows at bottom part. Use FooterRowCount property to specify the number of footer rows in the grid. Use Footer or Footers property of TColumnEh object to specify information which need to show in footer cells. Footers property useful then you have more then one footer rows. Footers is a collection of TColumnFooterEh objects where information from i-th aliment of collection will be show in i-th cell of footer column. In footer cell, it is possible to show: Sum value for specified field, record count, value of a specified field or static text. Use property Footer.ValueType or Footers[i].ValueType to specify which type of value will be show in footer cell. If ValueType = fvtStaticText, then set the property Value to specify text which need to show. If ValueType = fvtFieldValue, then you need to set property FieldName to specify field, value of which need to show. To force grid to calculate total values need to activate SumList (DBGridEh.SumList.Active := True). Set ValueType to fvtSum and grid must to show sum value of the column field in the footer cell, you can also specify Column.Footer.FieldName to calculate total value of the other field. Set ValueType to fvtCount to force grid to show count of records in the footer cell.
    定制网格数据单元 
    在数据单元中显示字段值为图形。 
    TDBGridEh allows to show bitmaps from TImageList component depending on field values. To show bitmaps depending on field values need: Fill list of field values to Column.KeyList property (every value in separate line) and set Column.ImageList property to ImageList control that has the bitmap in according index. Set Column.NotInKeyListIndex to index of bitmap that will be shown if field's value does not correspond to any value in KeyList (for instance you can set index of image for Null field value). At run time you are not allowed to edit bitmap in column cell. Use blank key and mouse click to set next value from Column.KeyList to the field; Shift-blank key and Shift-Mouse click to set previous value from Column.KeyList. Set Column.DblClickNextval to True have allows to change value on mouse double click. 检查框式的逻辑及非逻辑值
    Grid automatically shows checkboxes for boolean field. To show checkboxes for non boolean fields fill first line of Column.KeyList property that corresponds to the checked state of the checkbox, second line - non checked state, and set Column.Checkboxes ptoperty to True. Line of KeyList can represent more than one value in a semicolon-delimited list of items. 数据行高度 
    使用 RowHeight 和 RowLines 属性来指定数据行高。完整的数据行高 = 行线高度+行高。设置 RowSizingAllowed 为 True 以允许可以在运行是使用鼠标来改变行高。设置Column.WordWrap为True可以使数据行中文本多行显示。如果行高>文本行,它就换行。 显示备注字段 
    设置 DrawMemoText to True来显示文本式的备注字段。. 定制单元格字体及颜色 
    TDBGridEh 中的 Font 和 Color 属性描述了数据网格中绘制单元格的字体和颜色。
    TColumnEh 中的 Font 和 Color 属性描述了指定列中绘制单元格的字体和颜色。 事件定制单元格字体及颜色 
    有几个事件可以让你能够在绘制单元格前定制单元格字体和颜色。你可以写TDBGridEh的OnDrawColumnCellEvent事件句柄来在控制在网格单元中绘制数据。你可以使用Canvas属性的方法来绘制单元格。但是如果你只想改变字体或颜色的属性,我建议你使用下面的事件。你可以写TDBGridEh的OnGetCellParams事件来控制在绘制数据单元以前所指定的操作。你可以改变绘制字体及背景色。这个事件适合你在想改变整行的字体或颜色时使用。如果你想改变指定列中单元格的属性,你可以使用TColumnEh.OnGetCellParams。写这个事件用来控制在一列数据单元被重绘或编辑时的操作。在一列数据单元被重绘以前,你可以改变绘制字体,背景色,对齐方式,图像索引,文本或检查框。在编辑一列数据单元以前,你可以改变编辑字体,背景色,文本或只读状态。 列属性的默认值 
    使用ColumnDefValues属性来设置列属性的默认值。新创建的列将从ColumnDefValues属性中获得属性值,并且直到第一次为其指定值为止。在网格的适当位置放置编辑器. 
    在下拉列表中显示几个字段。 
    在下拉列表中显示几个下拉字段,需要设置列的LookupDisplayFields属性到字段的Semicolons属性来分割多个字段名。命名为Column.Field.LookupResultField的属性必须位于LookupDisplayFields列表中。多字段的下拉列表只能应用于下拉字段。 显示下拉方式的列 
    你可以通过KeyList 和 PickList 属性在相关的的字段中显示其它文本。KeyList显示包含在字段的值而非PickList索引所包含的值。 Column.NotInKeyListIndex to index of text from PickList that will be shown if field value do not contain in KeyList (for instance you can set index of text for Null field value). Set Column.DblClickNextval to True to change value on mouse double click. 下拉式计算器 
    对于 TDateField 和 TDateTimeField 字段,inplace 编辑器将显示下拉按钮以显示显示下拉计算器。设置 Column.ButtonStyle 为 cbsNone 以禁止显示下拉按钮。 设置编辑器颜色和字体 
    Inplace编辑器可以设置数据单元的颜色和字体。数据单元使用OnGetCellParams 事件来控制列的颜色和字体。 Inplace 编辑器在行高>一行的高度时自动设置为多行模式并且将列的属性 WordWrap 设置为True.自动填充网格列宽到网格客户区 
    设置AutoFitColWidths为True以自动重置列宽来设置网格的宽度等于客户区宽度。 MinAutoFitWidth 属性决定网格的最小宽度,列宽将会被重新计算。 3D或平面外观 
    使用 OptionsEh 属性来显示/隐藏固定的3D框架,冷区,页脚以及数据行。
    使用 Flat 属性来设置用平面方式显示数据网格。 从多种格式导入/导出数据到TDBGridEh 
    EhLib 的函数集可以从DBGridEh导出数据到Text, Csv, HTML, RTF, XLS以及其内部格式。它可以保存数据到流(TStream对象)或文件。 
      

  2.   

    例子
    Pascal: SaveDBGridEhToExportFile(TDBGridEhExportAsText,DBGridEh1,'c:\temp\file1.txt',False);
    C++: SaveDBGridEhToExportFile(__classid(TDBGridEhExportAsText),DBGridEh1,"c:\\temp\\file1.txt",false); EhLib 的函数集可以从 Text以及其内部格式的数据导入到DBGridEh的数据集中。它可以从文件中读取数据或读取数据到流(TStream对象)。 其它特性 
    用lookup 编辑器,你可以在运行时清空(设置为Null) LookupKeyField 值。比如选择整个文本然后按Delete键。 冷区 
    冷区是数据网格列集左边显示的不可滚动的区域。与固定列不同的是,冷区的列可以获得编辑焦点。可以通过设置FrozenCols属性来设置右边不可滚动的列集。 增量搜索 
    TDBGridEh 允许用户在网格列中实现特定的“增量”搜索。当用户进入增量搜索时他可以显示字符以及网格,并且在当前的列中查找文本。使用 dghIncSearch 和 dghPreferIncSearch的值(在OptionsEh 选项中) 在数据网格中操作增量搜索。 dghIncSearch 值允许在数据网格中进行增量搜索。运行时你能够使用下面的键进行增量搜索:
    Ctrl+F - 开始增量搜索。
    Ctrl+Enter - 查找下一个匹配记录。
    Ctrl+Shift+Enter - 查找前一个匹配记录。如果OptionsEh选项中的 dghIncSearch 是只读的,那么网络将自动设置增量模式在第一次按键以及1.5秒后返回普通模式。 dghPreferIncSearch 值决定网格设置自动增量搜索模式在第一次按键时替代单元编辑。水平或垂直滚动条 
    使用 VertSctollbar, HorzSctollbar 属性来显示/隐藏以及跟踪水平或垂直滚动条。 多选 
    TDBGridEh 允许在选定的区域上进行选择记录,列以及矩形区域等操作: 
    允许多选会影响下面这些属性:
    Options选项中的dgMultiSelect属性 - 设置是否允许多选。
    Options选项中的dghClearSelection 属性- 设置在用户移到下一个单元时是否清除已选记录。
    Options选项中的EditActions属性 -设置用户可以在已选记录上执行哪些操作(比如,拷贝,剪切,删除,粘贴,全选等)。 
    Options选项中的AllowedSelections属性-设置允许选定记录的类型(比如,行,列,矩形区域等)。 
    Options选项中的Selection属性-设置一个当前的多选状态,已选记录,列或矩形区域以及存取它们的属性和函数。 从注册表或ini文件中保存或恢复网格和列的层次 
    TDBGridEh 有一个常规设置来从注册表或ini文件中保存和恢复网络以及列的层次:
    RestoreColumnsLayout - 从注册表中恢复列的次序,宽度,排序标志。
    RestoreColumnsLayoutIni - 从ini文件中恢复列的次序,宽度,排序标志。 
    RestoreGridLayout - 从注册表中恢复列的次序,宽度,可视,排序标志,排序索引或行高。 
    RestoreGridLayoutIni - 从ini文件中恢复列的次序,宽度,可视,排序标志,排序索引或行高。 
    SaveColumnsLayout - 保存列的次序,宽度,排序标志到注册表中。 
    SaveColumnsLayoutIni - 保存列的次序,宽度,排序标志到ini文件中。 
    SaveGridLayout - 保存列的次序,宽度,可视,排序标志,排序索引或行高到注册表中。 
    SaveGridLayoutIni - 保存列的次序,宽度,可视,排序标志,排序索引或行高到ini文件中。 当前版本的TDBGridEh不支持的特性: 
    TDBGridEh 不能设置每一个数据窗口中单独行的行高。
    TDBGridEh 不能象TreeView那样工作。它不能拥有节点和枝叶。
    TDBGridEh 不能横向或纵向合并数据单元。 将已存在的TDBGrid组件转换为TDBGridEh组件: 尽管TDBGridEh并不是从TCustomDBGrid组件继承而来的,但是在TDBGridEh和TDBGrid中还是有一些相似的属性。 
    它允许仅用一点点代价来转换已存在的TDBGrid组件到TDBGridEh。
    可以按照下面的提示来转转换已存在的TDBGrid组件到TDBGridEh:
    在Delphi的IDE中打开包含有TDBGrid组件的应用程序。 设置视图方式为文本方式(Alt-F12)。 
    if key=VK_RETURN then //Key:回车
    begin
    if (grdDetailData.SelectedIndex=grdDetailData.Columns.Count-1) and not (dgRowSelect in grdDetailData.Options) then
    BEGIN
    if (dgEditing in grdDetailData.Options) and (grdDetailData.Row=grdDetailData.RowCount-1) then //从表GRID能进行编辑和当前光标焦点在最后一行时
    acAddDetailExecute(self)
    else
    begin
    grdDetailData.Row:=grdDetailData.Row+1; //改变光标焦点行到下一行(当为新增加时,这句不用运行
    grdDetailData.SelectedIndex:=0 //改变光标焦点列到第一列
    end;
    END ELSE
    BEGIN
    grdDetailData.SelectedIndex:=grdDetailData.SelectedIndex+1;
    while grdDetailData.Columns[grdDetailData.SelectedIndex].ReadOnly do
    grdDetailData.SelectedIndex:=grdDetailData.SelectedIndex+1;
    END;
    key:=0;
    end;
    if key=VK_INSERT then //Insert键:新增一条记录
    begin
    acAddDetailExecute(self);
    key:=0;
    end;
    if key=VK_DELETE then //Delte: 删除一条记录
    begin
    acDeleteDetailExecute(self);
    key:=0;
    end;页脚合计
    1、设置DBGRIDEH属性的FooterRowCount值为1;
    2、设置DBGRIDEH属性的SumList的Active值为true;
    3、设置你要求和的该列的Footer的ValueType类型为fvtSum;
    4、运行OK!
    在DataSet打开时写:
    DBGridEh1.Columns[0].Footer.Value := IntToStr(DBGridEh1.DataSource.DataSet.RecordCount); 
    [转载] 
     
      

  3.   

    关联一个imageList, 然后设置keyList。就OK 了
      

  4.   

    天下无雪的这点资料网上到处是,不过网上也只能找到这些了。楼主的问题最好是看看ehlib的DEMO1例子,网上对这个控件的资料不全。
    本人也在学习中,可以QQ交流一下:394503696