Solved

Color the colom of the selected cell

Posted on 2004-09-17
6
286 Views
Last Modified: 2010-04-05
A good morning to you all.

I have a string grid, with data in it.
Has 6 rows and 3 colums. Want I need to be able to do is color the colum that has the selected cell. So, If the click on a cell in coloum 2 that whole colums color becomes dark blue. Or if they selected a cell in coloum 1 that whole colums color would go dark blue.

Basically, it's getting the selected cells coloum and using that on the ondraw event - shouldn't be to hard :)
0
Comment
Question by:wildzero
  • 3
  • 3
6 Comments
 
LVL 22

Accepted Solution

by:
Ferruccio Accalai earned 125 total points
ID: 12089493
I assume that you've 1 fixed row and no fixed col...

var
  Form1: TForm1;
  BlueCol: Integer;
implementation

{$R *.dfm}

procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
begin
If (ACOl=BlueCOl) and (ARow > 0) then
   StringGrid1.Canvas.Brush.Color := clNavy
else
   StringGrid1.Canvas.Brush.Color := clWIndow ;
   StringGrid1.Canvas.FillRect(Rect);
end;

procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
begin
   BlueCOl := ACol;
   STringGrid1.Refresh;
end;

F68 ;-)
0
 
LVL 10

Author Comment

by:wildzero
ID: 12089504
LoL, didn't think of doing it that way - well done :)
Doing it that way also solves another problem I thought I was going to have!!

Top job and speedy reply.
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 12089512
Glad to have helped you :)

F68 ;-)
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 10

Author Comment

by:wildzero
ID: 12089519
Ohh one thing (if u got a sec)
Can I make it so when I click say, a button I can select a row in a certain cell in the string grid?
Ie, click button and on the string grid it selects stringgrid.cells[0,2]
Thought there would be a way to call stringgrid.select[0,2] but alas there isnt. If its a quick 5 seconds then sweet. Otherwise I will create a new question :)

Cheers
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 12089531
What about calling

Procedure TForm1.Button1CLick(Sender: TObject);
begin
   STringGrid1.Col := 0;
   StringGrid1.Row := 2;
end;
0
 
LVL 10

Author Comment

by:wildzero
ID: 12089762
Perfect :)
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
How to disable mouse scroll in a combo box field within a Delphi cxGrid 4 132
Newbie Thread Programming 1 151
Delphi selector screen 2 78
Delphi: making a BW image transparent 10 37
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…
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

776 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