打印本文 打印本文 关闭窗口 关闭窗口
Delphi自带的SpinEdit控件太丑了,自己写一个替换它
作者:武汉SEO闵涛  文章来源:敏韬网  点击数2777  更新时间:2009/4/23 18:30:38  文章录入:mintao  责任编辑:mintao
    end

    else

      if StrToInt(TEdit(Sender).Text + Key) < FMin then

      begin

        Key := #0;

        Exit;

      end;

 

 

 

end;

 

procedure TUpDownEdit.SetMax(const Value: Integer);

begin

  FMax := Value;

  UpDown.Max := FMax;

  if StrToIntDef(Edit.Text, 0) > FMax then

  begin

    UpDown.Position := FMax;

    Edit.Text := IntToStr(FMax);

    FPosition := UpDown.Position;

  end;

end;

 

procedure TUpDownEdit.SetMin(const Value: Integer);

begin

  FMin := Value;

  UpDown.Min := FMin;

  if StrToIntDef(Edit.Text, 0) < FMin then

  begin

    UpDown.Position := FMin;

    Edit.Text := IntToStr(FMin);

    FPosition := UpDown.Position;

    if Assigned(FOnChange) then

      FOnChange(Self);

  end;

end;

 

procedure TUpDownEdit.SetPosition(const Value: Integer);

begin

  if (Value >= FMin) or (Value <= FMax) then

  begin

    FPosition := Value;

    UpDown.Position := FPosition;

    Edit.Text := IntToStr(FPosition);

    if Assigned(FOnChange) then

      FOnChange(Self);

  end;

end;

 

procedure TUpDownEdit.UpDownClick(Sender: TObject; Button: TUDBtnType);

begin

  if Max = 0 then

  begin

    Max := 100;

    UpDown.Max := Max;

  end;

  UpDown.Min := Min;

  Edit.Text := IntToStr(UpDown.Position);

  Edit.SetFocus;

  Edit.SelectAll;

  if Assigned(FOnChange) then

    FOnChange(Self);

  FPosition := UpDown.Position;

上一页  [1] [2] [3] [4]  下一页

打印本文 打印本文 关闭窗口 关闭窗口