?
Solved

Check of entered text in TStringGrid

Posted on 2000-02-24
1
Medium Priority
?
315 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
[X]
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
1 Comment
 
LVL 8

Accepted Solution

by:
ZifNab earned 300 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 does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

764 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