Solved

Check of entered text in TStringGrid

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

690 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