Board index » delphi » TStringGrid ?'s

TStringGrid ?'s

Hello,

If anyone could help me with the following questions, it would be
greatly appreciated.

1.) How do you restrict the length of a TStringGrid field?

2.) How do you capitalize the first letter of every word in a field as  
   the user enters the characters?

3.) Does anyone know of a component or code to print a StringGrid      
report?

Shane Holmes

 

Re:TStringGrid ?'s


Quote
> 1.) How do you restrict the length of a TStringGrid field?

You can use the OnKeyPress event.  The Col and Row properties return the
current cell, to allow you to implement cell by cell checks if you so
desire.  If the key press will take the entry over your length use Key :=
#0;

Quote
> 2.) How do you capitalize the first letter of every word in a field as  
>    the user enters the characters?

OnKeyPress again, and the UpCase (I think) function.

Quote
> 3.) Does anyone know of a component or code to print a StringGrid      
> report?

Nope - but Printer.Canvas and a loop is quite easy to do

--
Mark Pritchard

Re:TStringGrid ?'s


Quote
shol...@rodin.wic.net (Shane Holmes) wrote:
>Hello,
>If anyone could help me with the following questions, it would be
>greatly appreciated.
>1.) How do you restrict the length of a TStringGrid field?
>2.) How do you capitalize the first letter of every word in a field as  
>   the user enters the characters?

1) and 2)

Waht about providing an editmask in the OnGetEditMask event?

procedure TForm1.StringGrid1GetEditMask(Sender: TObject; ACol,
  ARow: Longint; var Value: string);
begin
  Value := '>c<cccccccccccc'
end;

From the helpfile about EditMasks:
The c character permits a character in this position, but doesn't
require it.

If a > character appears in the mask, all characters that follow are
in uppercase until the end of the mask or until a < character is
encountered.

If a < character appears in the mask, all characters that follow are
in lowercase until the end of the mask or until a > character is
encountered.

Best regards,
Frank
--
// Frank Mikalsen, System Developer, Finale a.s      
// Homepage: http://home.sol.no/frankm
// Author of ShareWare: Silent Partner Backup Screensaver v2.60
// Download: http://www.winsite.com/pc/win3/desktop/spbck260.zip

Other Threads