Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Value List Editor

Posted on 2004-08-09
7
Medium Priority
?
1,563 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

670 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