Subject | Re: [IBO] Customize text in a TIB_Grid |
---|---|
Author | Dmitry Beloshistov |
Post date | 2002-11-13T17:57:51Z |
Hello, Armando!
You wrote to <IBObjects@yahoogroups.com> on Wed, 13 Nov 2002 14:08:28 -0300:
AN> The problem with 'TIB_Grid.OnGetDisplayText' is that this event not
AN> give me a reference to the field, but rather a reference to the
AN> column number related with the field. If the position of the column
AN> are changed, the code that I wrote for event would no longer work.
AN> How do I to obtain a reference to the field before to draw the cell
AN> ?.
I use this code :
Function GetCellDataColumn(Grid:TIB_Grid; ACol,ARow:integer):TIB_Column;
begin
Result:=nil;
if Assigned(Grid.DataSource) and (Grid.DataSource.Dataset<>nil) and
Grid.DataSource.Dataset.Active then
begin
with Grid.DataSource.Dataset do
begin
Grid.BufferRowNum:=Grid.DataRow[ARow];
if Grid.BufferRowNum>0 then Result:=Grid.GridFields[DataCol[ACol]];
end;
end;
End;
or your may rewrite GetCellDisplayText method of TIB_Grid...For example:
function TIB_MyGrid.GetCellDisplayText(ACol,ARow:integer):string;
var AColumn: TIB_Column;
begin
Result:=inherited GetCellDisplayText(ACol,ARow);
AColumn:=GetCellDataColumn(Self,ACol,ARow);
if AColumn<>nil then
begin
if AColumn.IsBlob then Result:='<IT IS BLOB>';
if AColumn.IsArray then Result:='<IT IS ARRAY>';
if AColumn.FieldName='MY_FIELD' then
begin
if AColumn.AsInteger<1000 then Result:='Correct!'
else Result:='Incorrect!'
end;
end;
end;
And OnGetDisplayText event work too ;))
WBR, Dmitry Beloshistov AKA [-=BDS=-]
e-mail: torin@...
You wrote to <IBObjects@yahoogroups.com> on Wed, 13 Nov 2002 14:08:28 -0300:
AN> The problem with 'TIB_Grid.OnGetDisplayText' is that this event not
AN> give me a reference to the field, but rather a reference to the
AN> column number related with the field. If the position of the column
AN> are changed, the code that I wrote for event would no longer work.
AN> How do I to obtain a reference to the field before to draw the cell
AN> ?.
I use this code :
Function GetCellDataColumn(Grid:TIB_Grid; ACol,ARow:integer):TIB_Column;
begin
Result:=nil;
if Assigned(Grid.DataSource) and (Grid.DataSource.Dataset<>nil) and
Grid.DataSource.Dataset.Active then
begin
with Grid.DataSource.Dataset do
begin
Grid.BufferRowNum:=Grid.DataRow[ARow];
if Grid.BufferRowNum>0 then Result:=Grid.GridFields[DataCol[ACol]];
end;
end;
End;
or your may rewrite GetCellDisplayText method of TIB_Grid...For example:
function TIB_MyGrid.GetCellDisplayText(ACol,ARow:integer):string;
var AColumn: TIB_Column;
begin
Result:=inherited GetCellDisplayText(ACol,ARow);
AColumn:=GetCellDataColumn(Self,ACol,ARow);
if AColumn<>nil then
begin
if AColumn.IsBlob then Result:='<IT IS BLOB>';
if AColumn.IsArray then Result:='<IT IS ARRAY>';
if AColumn.FieldName='MY_FIELD' then
begin
if AColumn.AsInteger<1000 then Result:='Correct!'
else Result:='Incorrect!'
end;
end;
end;
And OnGetDisplayText event work too ;))
WBR, Dmitry Beloshistov AKA [-=BDS=-]
e-mail: torin@...