With this version the user can set a color by editing for that moment , but when he clicks on the next row, the ugly color value can be seen e.g. -13383452
I only show the LabelName . The column's Editor is set to colorPicker, but when the user sets the color, the color value is set to LabelColor field.
I don't know how to use this.
procedure TMainForm.GridBeforeDrawCell(Sender: TObject;
AGraphics: TTMSFNCGraphics; ACell: TTMSFNCDataGridCell;
var ACanDraw: Boolean);
begin
If ACell.Row = 0 Then Exit;
If ACell.Column = 2 Then
Begin
ACell.DrawElements := ACell.DrawElements - [gcdText];
End;
end;
And when I started the program, it worked how I expected: I could choose the color with the Color Picker and then in the cell I could see only the color.
However when I quit the program and started it again, the previously colored records were "colorless", although in the database field the color codes were there.
So it seems the coloring works only for the freshly colored cells for that very session. How can I make this permanent?
I wasn't aware you were binding to a dataset. There are several ways to bind to a cell, by default the adapter only picks up the cell value. Since the color picker actually binds to the fill color, it's not picked up. You might need to change tactics. Attached is a sample demonstrating how to bind the color to the cell value instead and change the fill color of the cell dynamically based on the cell value.
Thank you very much for the sample. It works well.
Only there is a minor thing, which might confuse the user : if he clicks in a color cell, instead of not changing the cell color, it changes to the default cell coloring (have a look at the attached video).
The best thing would be to invoke the color editor immediately when the user clicks on the color cell.
Can this be done? Thank you very much!