Identifying column in OnDrawCell procedure

I'm trying to customize a wwDBGrid - the grid is attached to an ADO Dataset retrieving records from a stored procedure.  There's no DrawColumnCell procedure in the grid, but surely there must be an alternative?
Specifically I want to display a bitmap beside a field based on criteria, but only for one column.  Everything works fine, I just can't narrow it down to a single column.

Regards,
Bob
patelkalp_aAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RickJCommented:
The infopower grid has a selectedfield property. Would this work for you? example

if mygrid.selectedfield = mytablefield then
  docustompainting ;
0
RickJCommented:
Sorry think I misread the question.
I think the ondrawdatacell will give you what you need. It has access to the field in question.
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

diniludCommented:
procedure TForm1.wwDBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
0
patelkalp_aAuthor Commented:
My apologies, it was indeed the OnDrawDataCell procedure.
I've tried most of the properties, including selectedfield.  The fieldname never changes from that of column[0], despite the underlying value of the field being presented accurately.

In this code snippet found will never be turned on:

procedure TfMain.dbgCMS_DSPSRCMEMBERSDrawDataCell(Sender: TObject;
  const Rect: TRect; Field: TField; State: TGridDrawState);
var
  Found: Boolean;

begin
  if dbgDbGrid1.SelectedField.FieldName = 'FIELD2' then
  begin
     Found = True;
  end;
end;

  object dbgDbGrid1: TwwDBGrid
    Left = 296
    Top = 176
    Width = 377
    Height = 257
    DisableThemesInTitle = False
    Selected.Strings = (
      'FIELD1'#9'14'#9'Field 1 Desc'
      'FIELD2'#9'50'#9'Field 2 Desc'#9'F')
    IniAttributes.Delimiter = ';;'
    TitleColor = clBtnFace
    FixedCols = 0
    ShowHorzScrollBar = True
    DataSource = fData.dsDbGrid1
    Options = [dgAlwaysShowEditor, dgTitles, dgColLines, dgRowLines, dgRowSelect, dgAlwaysShowSelection, dgConfirmDelete, dgCancelOnExit, dgWordWrap]
    ParentShowHint = False
    ShowHint = False
    TabOrder = 2
    TitleAlignment = taLeftJustify
    TitleFont.Charset = DEFAULT_CHARSET
    TitleFont.Color = clWindowText
    TitleFont.Height = -11
    TitleFont.Name = 'MS Sans Serif'
    TitleFont.Style = []
    TitleLines = 1
    TitleButtons = False
0
RickJCommented:
In the OnDrawDataCell event you need to check the field parameter, like this

if Field = mytablefield2 then
    dbgDbGrid1.Canvas.Font.Color := clRed;
dbgDbGrid1.DefaultDrawDataCell(Rect, Field, State);
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RickJCommented:
Thanks, glad I could help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.