iosdelphifiremonkeydelphi-xe4firemonkey-fm3

Is there a way to set the Keyboard Type when entering a value in a StringGrid?


I would like to create an iOS App, with a fixed StringGrid. Every cell of this thing should only accept numeric values. For this I want to set the KeyboardType to vktNumberPad...but so far have not found a point of entry for this. Does anyone here have a clue on how to do this?

OK, so following Mikes hint I started to use my own column class.

TNumEditCell = class(TEdit)
end;
TNumberColum = class(TStringcolumn)
private
  function CreateCellControl: TStyledControl; override;
end;

And here comes the baffling part:

function TNumberColum.CreateCellControl: TStyledControl;
begin
  result := TNumEditCell.Create(Self);
  TNumEditCell(result).KeyboardType := vktNumberPad; // <- is undeclared!! What?!
  TNumEditCell(result).OnChange := DoTextChanged;
end;

Our good friend the compiler does not know what vktNumberPad is. Not even if I point him to it with a telephone pole FMX.Types.TVirtualKeyboardType(vktNumberPad). I guess I'm doing something wrong :(

Final edit: Indeed I did something wrong, as Peter pointed out. So with the code above and Peters hint everything works. Ummm...how do I finish this question?


Solution

  • Compiler doesn't know about vktNumberPad because you aren't addressing it correctly. use : TNumEditCell(result).KeyboardType := TVirtualKeyboardType.vktNumberPad