Solved

Value List Editor

Posted on 2004-08-09
7
1,552 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
Technology Partners: 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 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

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!

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

738 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