6

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?

7
  • For tedit, you can set the KeyboardType in the designer. Can't you do that with the tstringgrid?
    – Argalatyr
    Jun 18, 2013 at 12:44
  • Nope, not as simply as with the TEdit. At least I could not find the property.
    – Sherlock70
    Jun 18, 2013 at 14:32
  • 1
    A grid cell is simply a TEdit so should be no problem but you'll need a custom column class so you can set it in CreateCellControl - monkeystyler.com/guide/Custom-Grid-Columns Jun 18, 2013 at 19:17
  • @Sherlock70, have you tried to use a normal TEdit component with vktNumberPad? For me the VirtualKeyboard is always the same regardless which would point to a bug in the IFMXVirtualKeyboardService Interface.
    – Peter
    Jun 18, 2013 at 21:21
  • @PeterVonča, TEdit with vktNumberPad works fine in the same App. BUT I'm using the demo version of X4...could that be the reason why my latest efforts are fruitless?
    – Sherlock70
    Jun 19, 2013 at 7:10

2 Answers 2

2

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

0

Just go to de column properties and in Column style select Currency column, or Float Column, depending on the type of column will be the kind of Keyboard showsen.

0

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.