Subject Re: Icons in TIB_Grid
Author georgethenorge
I used a TIB_ControlGrid instead of the TIB_Grid. Then I used a
TIB_Text control. From version 4 it has a Canvas you can paint to.
The event you use is TIB_Text.GetDisplayText.

This is what I did:
procedure Form1.MyIB_Text.GetDisplayText(Sender: TObject; var
AString: String);
var
B:TBitmap;
iIndex: integer;
begin

B := TBitmap.create;
iIndex := strtointdef(AString, 0); //gets the index of the bitmap
ImageList.GetBitmap(iIndex, B); //get the right bitmap
MyIB_Text.canvas.draw(0,0,B); //render the image
B.Free;
AString := ''; //stops the text from being printed


A little tip - do not make TIB_Text.Autosize = True. Let's just
call the result a nice little bug for JW and co. to have some fun
figuring out.

Hope it helps,
George Helmke


--- In IBObjects@y..., Ale¹ Kahánek <ales.kahanek@n...> wrote:
> Hi,
> does anybody have some experience with drawing icons in TIB_Grid? I
would
> prefer to create TIB_Grid descendant with property ImageList and
posibility
> to draw Icons on the basis of icon numbers in the associated
dataset´s
> column.
>
> Example
> CREATE TABLE MYTABLE(
> ID INTEGER,
> ICON INTEGER, /*this is number of the desired icon from the image
list*/
> ANOTHERFIELD VARCHAR(20),
> ...
> )
>
> In the TIB_Query.CollumnAttributes I can specify this entry
> ICON=BMP_FIELD=1
> and then in the drawing method I could test if the BMP_FIELD
attribute is
> set to 1. But, what is the best TIB_Grid method to override when
drawing the
> icon?
>
> Or is there better solution?
>
> Thanks in advance.
> Ales Kahanek>
> > Thanks in advance.
> > Ales Kahanek
> >