Solved

Color the colom of the selected cell

Posted on 2004-09-17
6
290 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 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 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses
Course of the Month8 days, 21 hours left to enroll

615 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