Solved

Detect resize on stringgrid column

Posted on 2000-05-11
2
1,479 Views
Last Modified: 2008-03-03
In Delphi 5, is there a way to detect when a TStringGrid column is being resized?
0
Comment
Question by:jpoz
2 Comments
 
LVL 2

Accepted Solution

by:
rene100 earned 10 total points
ID: 2802023
ok, here it comes:

unit StringGridEx;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Grids;

type
  TStringGridEx = class(TStringGrid)
  private
    FColWidthsChanged: TNotifyEvent;
    procedure ColWidthsChanged; override;
    { Private declarations }
  protected
    { Protected declarations }
  public
    { Public declarations }
  published
    property OnColWidthsChanged: TNotifyEvent read FColWidthsChanged write FColWidthsChanged;
    { Published declarations }
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Eigene', [TStringGridEx]);
end;

procedure tStringgridEx.ColWidthsChanged;
begin
inherited;
if Assigned(OnColWidthsChanged) then
   OnColWidthsChanged(Self)
end;
end.

now every time the width of a column has has been changed, OnColWidthsChanged is called.

regards
rene



0
 

Author Comment

by:jpoz
ID: 2802176
Very quick reply, I actually came up with another solution.  However, 'A' for effort, you can have the points.

My answer - in OnMouseUp, I determined where the mouse was based on the CellRect, and determined if it was within the area where the resize occurs.

procedure StringGrid1.OnMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState;
  X, Y: Integer)
var
  CellRect : TRect;
begin
  CellRect :=
    StringGrid1.CellRect(CellCoord.x,
                         CellCoord.y);

  if (x >= (CellRect.Right-3))
     or (x <= (CellRect.Left+3)) then
   { resize detected }
end;
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
FMX StringGrid1->Canvas->FillRect Problem 3 127
When I am typing into a TEdit last word repeats 7 117
SUM 2 INTEGER ARRAYS INTO 1 10 93
Firemonkey webbrowser scrollbars ? 1 29
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

910 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

21 Experts available now in Live!

Get 1:1 Help Now