?
Solved

Color the colom of the selected cell

Posted on 2004-09-17
6
Medium Priority
?
294 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
[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
6 Comments
 
LVL 23

Accepted Solution

by:
Ferruccio Accalai earned 500 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 23

Expert Comment

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

F68 ;-)
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 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 23

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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

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…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

719 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