patelkalp_a
asked on
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
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
Sorry think I misread the question.
I think the ondrawdatacell will give you what you need. It has access to the field in question.
I think the ondrawdatacell will give you what you need. It has access to the field in question.
procedure TForm1.wwDBGrid1DrawDataCe ll(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
Field: TField; State: TGridDrawState);
ASKER
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_DSPSRCMEMBER SDrawDataC ell(Sender : TObject;
const Rect: TRect; Field: TField; State: TGridDrawState);
var
Found: Boolean;
begin
if dbgDbGrid1.SelectedField.F ieldName = '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
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_DSPSRCMEMBER
const Rect: TRect; Field: TField; State: TGridDrawState);
var
Found: Boolean;
begin
if dbgDbGrid1.SelectedField.F
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks, glad I could help.
if mygrid.selectedfield = mytablefield then
docustompainting ;