문제

We are working in Delphi 2006 with devexpress.

We have a cxGrid. We want to restrict the entry of values for a number column, integers between 0 and 999. If I set the property type to a SpinEdit the initial value is always 0 which is unwanted.

So I left the property value on the column null and set the datatype on the databinding of the column to Smallint. That works for the most part but an 'e' and '.' and '+' and '-' can still be entered into the column which causes exceptions.

Is some simple way to exclude the 'e' and '.' and '+' and '-' from being entered into the column?

도움이 되었습니까?

해결책

The initial 0 Value can be prevented by setting UseNullString to true.

The input of unwanted characters can handled by

procedure TForm1.ViewEditKeyPress(Sender: TcxCustomGridTableView; AItem: TcxCustomGridTableItem;
  AEdit: TcxCustomEdit; var Key: Char);
begin
   if AItem = TheColumnWithSpinEdit then
     if (not (Key in ['0'..'9',#8])) then Key := #0;
end;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top