Solved

TDrawGrid..can it do this????????????????

Posted on 2002-04-12
7
226 Views
Last Modified: 2010-04-04
hihi..
  I want to use TDrawGrid to finish the following function,can it do this??????????
Wanted Function:
  When I click on a grid the color of the current grid can change. or just like :
   DrawGrid1.Rect(1,2).Color:=clBlue;
can I?????????????????????????????????????
                               wind
0
Comment
Question by:windyui
  • 3
  • 2
  • 2
7 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6936251
yes, could be done,
but not in this way

DrawGrid1.Rect(1,2).Color:=clBlue;

look at the ownerdraw-features

more points, more advice

meikl ;-)
0
 
LVL 9

Accepted Solution

by:
ITugay earned 39 total points
ID: 6936404
Hi windyui,

it looks like all of yours available points :-)

meikl :-)

may be something like this?

procedure TForm1.DrawGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
begin
  with DrawGrid1 do
  begin
    if gdSelected in State then
      Canvas.Brush.Color := clLime;
    Canvas.FillRect(CellRect(ACol, ARow));
  end;
end;

----
Igor.


0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6936414
>it looks like all of yours available points :-)

guessing no,
member since 1999, question asked 10
must have thousends of points

for q lower 50 pts i gave only hints

hi igor ;-)
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 9

Expert Comment

by:ITugay
ID: 6936425
oh nooooooooo, it was a trick! :-)
0
 

Author Comment

by:windyui
ID: 6936769
Hi, Igor
   Yor are almost Right. the Currect answer is
on the ONMOUSEDOWN Event:
begin
 MouseToCell(X,Y,Col,Row);
 with DrawGrid1 do
 begin
   Canvas.Brush.Color := clLime;
   Canvas.FillRect(CellRect(ACol, ARow));
 end;
end;

0
 
LVL 9

Expert Comment

by:ITugay
ID: 6938520
hi windyui,

not very sure about your solution. Let suppose you need to show any text or graphic in cell. Then you have to write OnDrawCell implementation and the same code for OnMouseDown event. So, OnMouseDown is only partial solution, however OnDrawCell is more logical and universal one.

and I think that you code wouldn't work even if you specify DefaultDrawing = False:

1. MouseToCell(X,Y,Col,Row); should be bellow "with DrawGrid1 do"
2. you can't pass Col and Row as parameters to MouseToCell
3. after Grid will be repainted, all cell's will be white again.

to solve this problem you have to store cell's colors somewhere, let say in matrix.

------
Igor

0
 

Author Comment

by:windyui
ID: 6940124
HI,Igor
   Yes you r right.WHen other windows upon (e.g. The Message window) the Cells ,the color LOST and become white again.
   I will try to store the color in a Matrix.Thx...


                                           windyui
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

757 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

16 Experts available now in Live!

Get 1:1 Help Now