Solved

Check of entered text in TStringGrid

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 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

13 Experts available now in Live!

Get 1:1 Help Now