delphi TDBEdit里面怎么设置默认的输入格式呢?

a861465724 2015-11-04 09:53:40
比如出院日期这个,,,怎样在焦点进入后只能输入默认的日期格式呢
...全文
289 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
doloopcn 2015-11-04
  • 打赏
  • 举报
回复
你上机测试一下不就知道了 最简单的测试就是:TMASKEDIT(YOURDBEDIT).EDITMASK:='######.##';
a861465724 2015-11-04
  • 打赏
  • 举报
回复
TMaskEdit 跟 TDBEdit组件是一个组件么,,,,还有上面的代码基本全都要么,,感觉应该没得这么多啊
doloopcn 2015-11-04
  • 打赏
  • 举报
回复
TMaskEdit(你的edit控件).EditMask
doloopcn 2015-11-04
  • 打赏
  • 举报
回复
procedure TForm1.FormCreate(Sender: TObject); begin { Initialize the maskedit boxes to contain the empty string. } MaskEdit1.Text := ''; MaskEdit2.Text := ''; MaskEdit3.Text := ''; { Use the Courier font in the maskedit boxes. } MaskEdit1.Font.Name := 'Courier'; MaskEdit2.Font.Name := 'Courier'; MaskEdit3.Font.Name := 'Courier'; { Initialize the mask of each maskedit box according to IP address coding conventions. } MaskEdit1.EditMask := '!099.099.099.099;1; '; MaskEdit2.EditMask := '!099.099.099.099;1; '; MaskEdit3.EditMask := '!099.099.099.099;1; '; MaskEdit2.OnExit := MaskEdit2Exit; end; procedure TForm1.MaskEdit2Exit(Sender: TObject); var net1, net2, host1, host2, netmask1, netmask2, hostmask1, hostmask2, sub_net1, sub_net2, sub_host1, sub_host2: Integer; IP, mask: String; begin // Extract the net and host address from the IP. IP := MaskEdit1.Text; net1 := StrToInt(TrimRight(Copy(IP, 0, 3))); net2 := StrToInt(TrimRight(Copy(IP, 5, 3))); host1 := StrToInt(TrimRight(Copy(IP, 9, 3))); host2 := StrToInt(TrimRight(Copy(IP, 13, 3))); // A range test that you cannot validate through edit masks. if ((net1 < 0) Or (net1 > 255) Or (net2 < 0) Or (net2 > 255) Or (host1 < 0) Or (host1 > 255) Or (host2 < 0) Or (host2 > 255)) then raise EArgumentException.Create('Not a valid IP address.'); // Extract the net and host mask from the subnet mask. mask := MaskEdit2.Text; netmask1 := StrToInt(TrimRight(Copy(mask, 0, 3))); netmask2 := StrToInt(TrimRight(Copy(mask, 5, 3))); hostmask1 := StrToInt(TrimRight(Copy(mask, 9, 3))); hostmask2 := StrToInt(TrimRight(Copy(mask, 13, 3))); // A range test that you cannot validate through edit masks. if ((netmask1 < 0) Or (netmask1 > 255) Or (netmask2 < 0) Or (netmask2 > 255) Or (hostmask1 < 0) Or (hostmask1 > 255) Or (hostmask2 < 0) Or (hostmask2 > 255)) then raise EArgumentException.Create('Not a valid subnet mask.'); // Compute the subnet address using bitwise AND. sub_net1 := net1 And netmask1; sub_net2 := net2 And netmask2; sub_host1 := host1 And hostmask1; sub_host2 := host2 And hostmask2; // Display the subnet address. MaskEdit3.Text := IntToStr(sub_net1) + '.' + IntToStr(sub_net2) + '.' + IntToStr(sub_host1) + '.' + IntToStr(sub_host2); end; 上面的是XE8自带的例子
a861465724 2015-11-04
  • 打赏
  • 举报
回复
谢谢,,虽然没用到你的方法,但还是可以了

2,507

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧