Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Trap Resize of Column in a TDBGrid

entrodusentrodus Member Posts: 5
Anyone has any sugestion on how to trap a
resize of a column in a TDBGrid?

Thanx in Advance


Comments

  • zibadianzibadian Member Posts: 6,349
    : Anyone has any sugestion on how to trap a
    : resize of a column in a TDBGrid?
    :
    : Thanx in Advance
    :
    :
    :
    Have you tried to exclude the dgColumnResize from the Options?
  • entrodusentrodus Member Posts: 5
    i do want the user to be able to resize a column in the grid
    i just cant find a way to trap whenever this happens.

    : : Anyone has any sugestion on how to trap a
    : : resize of a column in a TDBGrid?
    : :
    : : Thanx in Advance
    : :
    : :
    : :
    : Have you tried to exclude the dgColumnResize from the Options?
    :

  • zibadianzibadian Member Posts: 6,349
    : i do want the user to be able to resize a column in the grid
    : i just cant find a way to trap whenever this happens.
    :
    : : : Anyone has any sugestion on how to trap a
    : : : resize of a column in a TDBGrid?
    : : :
    : : : Thanx in Advance
    : : :
    : : :
    : : :
    : : Have you tried to exclude the dgColumnResize from the Options?
    : :
    :
    :
    I've not found an easy way to do this. The only way I found was to create a descendant of the TDBGrid object and override a single procedure. Here is the untested code, should you be interested:
    [code]
    unit MyDBGrid;

    interface

    type
    TMyDBGrid = class(TDBGrid)
    private
    FOnColResize: TNotifyEvent;
    protected
    procedure ColWidthsChanged; override;
    public
    published
    property OnColResize: TNotifyEvent read FOnColResize write FOnColResize;
    end;

    implementation

    { TMyDBGrid }

    procedure TMyDBGrid.ColWidthsChanged;
    begin
    inherited;
    if (Datalink.Active or (Columns.State = csCustomized)) and
    AcquireLayoutLock and Assigned(FOnColResize) then
    FOnColResize(Self);
    end;

    end.
    [/code]
    I cannot help you much with registering this class with the Delphi IDE. The additional parts of the if-then statement make sure that the event is only fired, when the user changes the size, not when the form is created.
Sign In or Register to comment.