Saturday 15 August 2015

Delphi mask for binary numbers -


I have a string grid and want only cells in it 1 or 0 . I try to use StringGridGetEditMask

  Process TForm1.StringGrid1GetEditMask (Sender: Tubect; ​​Acol, Arrow: integer; var value: string); Starting value: = '0'; If not ([0,1] in strontone (value) then value: = # 0; End;   

But I can input all the numbers from 0 to 9. How do I filter all the numbers except 0 and 1?

For your intentions you will need a sub-class of the class and in these sub-classes the in-site editor Allocate examples of this event in the Interposor class:

  Type TStringGrid = class (Grids.TStringGrid) Personal process InplaceEditKeyPress (Sender: TOBject; var key: four); Protected function CreateEditor: TInplaceEdit; Override; End; Implementation {TStringGrid} function TStringGrid.CreateEditor: TInplaceEdit; Start the result: = inherited CreateEditor; TMaskEdit (Results) .OnKeyPress: = InplaceEditKeyPress; End; Process TStringGrid.InplaceEditKeyPress (Sender: TOBject; var key: four); If not start (# 8, '0', '1'] key) then key: = # 0; End;    

No comments:

Post a Comment