Solved

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

Posted on 2002-04-12
7
229 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
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 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

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

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