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
Solved

Check of entered text in TStringGrid

Posted on 2000-02-24
1
312 Views
Last Modified: 2010-04-04
Hi, following:

have a TStringGrid with
 fixedcols:=0;
 fixedrows:=0;
 options:=[goFixedVertLine,
           goFixedHorzLine,
           goVertLine,
           goHorzLine,
           goEditing,
           goAlwaysShowEditor];

If the user set the focus from the actual cell to
somewhere else (to a different cell or eaven to a different control)
I need to check the users input at the cell he leaves this moment.
I try "OnSetEditText", but this event occurs immediately if the user
enters the first Char to the cell. (Ex.: the cells contain date-information,
and I want to check whether the entered date is a correct date...)

It exists a "private" procedure

procedure FocusCell(ACol, ARow: Longint; MoveAnchor: Boolean);

in TCustomGrid, if this whould be only "protected" and "virtual", it would
solve the problm, but unfortunately it isnt.

OK I could start to change VCL-Source for my needs, but first I would ask
if there is a solution without such an "operation".

Regards
nmm
0
Comment
Question by:nmm
1 Comment
 
LVL 8

Accepted Solution

by:
ZifNab earned 100 total points
ID: 2556144
Hi nmm,

you could do it like this :

* use the OnExit Event (leaving stringgrid)
* OnSelectCell Event (moving to another Cell)

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls, TeeProcs, TeEngine, Chart, Buttons, Grids;

type
  TForm1 = class(TForm)
    StringGrid1: TStringGrid;
    procedure StringGrid1Exit(Sender: TObject);
    procedure StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer;
      var CanSelect: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation
{$R *.DFM}

procedure TForm1.StringGrid1Exit(Sender: TObject);
// Event when focus goes to another component
begin
  with (Sender as TStringGrid) do
  begin
    if Cells[Col,Row] = 'Correct' then ;
  end;
end;

procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
// Event when changing cell
begin
  with (Sender as TStringGrid) do
  begin
    // Col and Row contain the Old position
    // ACol and ARow are the new positions
    if Cells[Col,Row] = 'Correct' then ;
  end;
end;

end.

Regards, Zif
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

837 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