Solved

Value List Editor

Posted on 2004-08-09
7
1,544 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Syntax Check Delphi Seattle IOS app without MAC ? 1 96
Simple Delphi Question 9 89
Delphi...Split view - idea? 1 67
Tidtcpserver listening on multiports? 1 26
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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 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

14 Experts available now in Live!

Get 1:1 Help Now