Solved

Value List Editor

Posted on 2004-08-09
7
1,538 Views
Last Modified: 2012-05-05
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;
0
Comment
Question by:yehiaeg
  • 3
  • 3
7 Comments
 
LVL 7

Expert Comment

by:LRHGuy
ID: 11759334
This works for me, but you have to have the goRowSelect option turned on...

procedure TForm2.vleDrawCell(Sender: TObject; ACol,
  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.Row];
    if (Item<>nil) and (Item.KeyDesc<> '') then
      T:=Item.KeyDesc
    else
      T:=vle.Cells[ACol, ARow];
    vle.Canvas.TextRect(Rect,Rect.Left+2,Rect.Top+2,T);
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
0
 

Author Comment

by:yehiaeg
ID: 11760058
yea but when goRowSelect is on, i can't edit the second column
0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 11760646
Did you set DefaultDrawing to False? This is required if you don't want the editor to draw over your own drawings. :-)
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 7

Expert Comment

by:LRHGuy
ID: 11761547
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.
0
 

Author Comment

by:yehiaeg
ID: 11761942
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?
0
 
LVL 7

Accepted Solution

by:
LRHGuy earned 125 total points
ID: 11762303
Ok, try this...

set goRowSelect to false.

In the onselectcell event, put:

vle.invalidate

Everything else should stay as in my example.

That fixed it here!
0
 

Author Comment

by:yehiaeg
ID: 11763669
thanks man, keep answering, have lots of other questions about value list editor
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now