powerbuilder:如何确保数据窗口中的文本字段不为空?
我有一个正在使用 pfc 服务的用户对象。现在,在更新过程中,如何确保数据窗口中的文本字段不为空?
I have a user object which is using pfc services. Now, during update, how can I make sure that a text field in datawindow is not empty?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
PFC 有一个 DataWindow 必需列服务,该服务可以更改列的必需属性的行为以在保存时进行评估。如果您的要求涉及编辑掩码列,则这将不起作用,但可能是实现此目的的简单方法。
为了使用它,我将以下代码放入构造函数中(警告:我已经有一段时间没有使用它了):
祝你好运,
Terry。
PFC has a DataWindow Required Column service, that changes the behaviour of columns' Required attribute to evaluate at save time. If your requirement involves editmask columns, this won't work, but may be an easy way to achieve this otherwise.
To use this, I'd put the following code in the Constructor (warning: it's been a while since I've used it):
Good luck,
Terry.
我将尝试解释我使用的方法,以确保用户不会将指定字段留空。以下是我放入 u_dw(祖先)的 pfc_updateprep 事件中的代码。然后,对于我希望在任何情况下都给出值的每一列,我在文本字段的
tag
属性中放置一个M
。描述该列的strong>。 HTH。I will try to explain the method that I use in order to make sure that a user will not leave a specified field empty. The following is the code that I have put in the pfc_updateprep event of u_dw (the ancestor). Then, for each one of the columns that I want a value to be given in any case, I put an
M
in thetag
property of the textfield that describes the column. HTH.我在 PB 中所做的是将以下数据窗口列属性设置为 TRUE 或选中:
如果执行此操作,数据窗口应自动为您验证该字段并防止用户将该字段留空。
[编辑 - Terry 总是好的建议后的澄清]
我的帖子的第一部分应该适用于数据输入时的文本字段,我相信将强制用户在允许焦点更改之前在 dw 中输入有效值,除非您修改该行为,例如,在 itemchanged 事件中。
可以打开 PFC 所需列服务并向其注册列以提供节省时间的验证。这使得用户在导航字段时在字段中移动变得不那么麻烦,并且只会在用户尝试保存时困扰他们。
What I've done in PB is to set the following datawindow column properties to TRUE or checked:
If you do this, the datawindow should automatically validate the field for you and prevent the user from leaving the field blank.
[EDIT - Clarification after Terry's always good advice]
The first part of my post should work for text fields at data entry time and I believe will force the user to enter a valid value in the dw before allowing focus to change unless you modify that behavior, for example, in the itemchanged event.
The PFC Required Column service can be turned on and the column registered with it to provide save-time validation. This makes it less cumbersome for a user to move through the fields while navigating the fields, and only pesters the user when they try to save.