Solved

Check of entered text in TStringGrid

Posted on 2000-02-24
1
311 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

809 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