View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0001358 | JEDI VCL | 00 JVCL Components | public | 2004-02-23 02:11 | 2004-04-22 01:10 |
| Reporter | fbc | Assigned To | user72 | ||
| Priority | normal | Severity | minor | Reproducibility | always |
| Status | closed | Resolution | fixed | ||
| Product Version | |||||
| Target Version | Fixed in Version | ||||
| Summary | 0001358: JvDBGrid OnGetCellParams var BackGround | ||||
| Description | Backround color in this event does not reflect the color of a selected cell (RowSelect := true) but just the background color of the control. | ||||
| Additional Information | I use this event to suppress unwanted data (i.e. 0 dates, shown as 31/12/1899) by changing the font.color to be the same as background; since Background is not changed, I end up with '31/12/1899' in white on the selected row. | ||||
| Tags | No tags attached. | ||||
|
|
I would suggest using OnGetText and OnSetText instead. That's what they are for. |
|
|
OnGetText is not a puplished event in my JvDBGrid. Here is a fix for the problem (marked FBC): (Please also look at the part marked ????? what is the purpose, ABack is never used) procedure TJvDBGrid.GetCellProps(Field: TField; AFont: TFont; var Background: TColor; Highlight: Boolean); var AColor, ABack: TColor; function IsAfterFixedCols: Boolean; var I: Integer; begin Result := True; for I := 0 to FixedCols - 1 do if Columns.Items[I].FieldName = Field.FieldName then begin Result := False; Break; end; end; begin if (FCurrentDrawRow >= FixedRows) and Odd(FCurrentDrawRow + FixedRows) and (FAlternateRowColor <> clNone) and (FAlternateRowColor <> Color) and IsAfterFixedCols then Background := AlternateRowColor; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // FBC: New place for Highlight code // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // Lionel if Highlight then begin AFont.Color := clHighlightText; Background := clHighlight; end; // End Lionel if Assigned(FOnGetCellParams) then FOnGetCellParams(Self, Field, AFont, Background, Highlight) else if Assigned(FOnGetCellProps) then begin // ???????? Strange code, what is ABack doing ?????????? if Highlight then begin AColor := AFont.Color; FOnGetCellProps(Self, Field, AFont, ABack); AFont.Color := AColor; end else FOnGetCellProps(Self, Field, AFont, Background); end; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // FBC: Remove this part, overwrites any changes done in events // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // Lionel //if Highlight then //begin // AFont.Color := clHighlightText; // Background := clHighlight; //end; // End Lionel end; regards Flemming edited on: 02-23-04 23:25 |
|
|
>OnGetText is not a puplished event in my JvDBGrid. Sorry, they are published in the TField class, not DBGrid >(Please also look at the part marked ????? what is the purpose, >ABack is never used) It's just a dummy parameter (it's a var, so required) when Highlight is true. Neither the font color nor the background color is used from OnGetCellProps in this case. > Here is a fix for the problem (marked FBC): Thanks, will add to CVS |
|
|
BTW, wouldn't it be better to just change the code to: if Assigned(FOnGetCellParams) then FOnGetCellParams(Self, Field, AFont, Background, Highlight) else if Assigned(FOnGetCellProps) then FOnGetCellProps(Self, Field, AFont, Background); Whouldn't it be nice to allow to change the font and background color even if Highlight is true? Can you see any side-effects of allowing it? |
|
|
I can't see how there could be a problem, there is no law saying you HAVE to write code in the event-procedure :-) BTW: Do we need both GetCellParams and GetCellProps, they do (almost) the same thing and are called from the same place. Flemming |
|
|
OnGetCellProps is marked as obsolete but I am a bit hesitant removing it... |
|
|
I can understand that. Let's make the other changes, and close this issue. |
|
|
Fixed in CVS |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2004-02-23 02:11 | fbc | New Issue | |
| 2004-02-23 08:18 |
|
Note Added: 0003010 | |
| 2004-02-23 23:11 | fbc | Note Added: 0003017 | |
| 2004-02-23 23:25 | fbc | Note Edited: 0003017 | |
| 2004-02-24 05:04 |
|
Note Added: 0003037 | |
| 2004-02-24 05:04 |
|
Status | new => assigned |
| 2004-02-24 05:04 |
|
Assigned To | => user72 |
| 2004-02-24 05:06 |
|
Note Added: 0003038 | |
| 2004-02-24 05:12 |
|
Status | assigned => feedback |
| 2004-02-24 05:21 | fbc | Note Added: 0003039 | |
| 2004-02-24 06:13 |
|
Note Added: 0003040 | |
| 2004-02-24 06:30 | fbc | Note Added: 0003042 | |
| 2004-02-24 08:38 |
|
Status | feedback => resolved |
| 2004-02-24 08:38 |
|
Resolution | open => fixed |
| 2004-02-24 08:38 |
|
Note Added: 0003044 | |
| 2004-04-22 01:10 |
|
Status | resolved => closed |