yehiaeg
asked on
Value List Editor
hello,
was using the value list editor, i wanted to change the color of the cell (first column) to clRed when the cell (second column) is edited , i tried this code in the DrawCellEvent :
if (gdFocused in State) then begin
vle.Canvas.Brush.Color := clRed;
vle.Canvas.FillRect(Rect);
end;
was using the value list editor, i wanted to change the color of the cell (first column) to clRed when the cell (second column) is edited , i tried this code in the DrawCellEvent :
if (gdFocused in State) then begin
vle.Canvas.Brush.Color := clRed;
vle.Canvas.FillRect(Rect);
end;
ASKER
yea but when goRowSelect is on, i can't edit the second column
Did you set DefaultDrawing to False? This is required if you don't want the editor to draw over your own drawings. :-)
From what I can tell, setting DefaultDrawing to false means you MUST draw the complete cell, everytime. Leaving it at True will have the component draw the cell, then call the onDrawCell event. The event method is called after the cell is drawn (DefaultDrawing=true) or after the drawing is skipped (DefaultDrawing=false).
My example leaves DefaultDrawing=true, then only draws column 0 of the active row.
My example leaves DefaultDrawing=true, then only draws column 0 of the active row.
ASKER
guys, it draw correctly when setting goRowselect to true, but the PROBLEM IS i can't edit anything now in the cells, cause when setting goRowSelect to True goAlwaysShowEditor is turned to False automatically,
when setting goRowSelect to false, i can now edit any cell but the drawcell event won't work,
any ideas?
when setting goRowSelect to false, i can now edit any cell but the drawcell event won't work,
any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks man, keep answering, have lots of other questions about value list editor
procedure TForm2.vleDrawCell(Sender:
ARow: Integer; Rect: TRect; State: TGridDrawState);
var
T:string;
Item:TItemProp;
begin
if (ARow=vle.Row)
and (ACol=0)
then begin
vle.Canvas.Brush.Color := clRed;
vle.Canvas.FillRect(Rect);
Item:=vle.ItemProps[vle.Ro
if (Item<>nil) and (Item.KeyDesc<> '') then
T:=Item.KeyDesc
else
T:=vle.Cells[ACol, ARow];
vle.Canvas.TextRect(Rect,R
end;
end;
object vle: TValueListEditor
Left = 16
Top = 108
Width = 306
Height = 144
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goDrawFocusSelected, goColSizing, goEditing, goRowSelect, goThumbTracking]
Strings.Strings = (
'one=two'
'three=four'
'five=six')
TabOrder = 2
OnDrawCell = vleDrawCell
end