从表单上的选定控件创建字符串 [英] Create string from selected controls on a form

查看:45
本文介绍了从表单上的选定控件创建字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含五列和16行控件的表单。从左到右,每行包含一个标签,一个从查询填充的绑定和锁定文本框,两个复选框和另一个未绑定的文本框。我附上了一个状态为On On Load的截图(staff-form.jpg)。正如您所见,右侧复选框以及右侧文本框可见= false。为了解释,我将使用以下作为控件名称:


名称复选框= chkName(位于标签名称下)

标题复选框= chkTitle(位于标题标题,目前隐藏在这个例子中)

标题textbox = txtTitle(位于标签下面包括标题,目前隐藏在这个例子中)


这个通过双击另一个表单上的文本框打开表单,用于选择参加酒店最近调查的人员。如果勾选了第1行的chkName,则行1的chkTitle变为可见。如果勾选了chkTitle,则标签下的文本框Please include Title对于第1行变得可见。取消这些可以反转它们的可见性。 txtTitle具有可以覆盖的默认值。对于Tom Smith,txtTitle的默认值是General Manager。对于与Bob Jones在同一部门工作的Tim Allan,txtTitle的默认值是这个人的头衔是什么?。在这种情况下,适当的标题将由用户键入。此功能目前正在运行。


我希望选择的项目创建一个将放置在调用文本框中的字符串。部分完成的表格将有助于解释我希望接下来会发生什么。在附带的截图中,Bob,Tim和Stan都参与了这项调查。用户希望展示鲍勃和蒂姆的头衔而不是斯坦的头衔。蒂姆的头衔被担任助理总监。请参阅随附的屏幕截图(staff-form-filled.jpg)。


此屏幕截图的结果字符串应为:


Bob Jones ,食品和饮料总监;助理主任蒂姆艾伦; Stan Laurel


这可能吗?请帮助我了解如何实现这一目标。


感谢您对我的项目的帮助。


**编辑**
Staff-Form.jpg


Staff-Form-Filled.jpg

< fieldset class =fieldset> Attached Images
(42.6 KB,751 views)

解决方案

  1. 通过表格中的所有控件迭代,使用严格的命名约定来识别特定于每一行的控件,如:

    展开 | 选择 | Wrap | 行号


嗨ADezii,


Arghh!我似乎无法理解这一点,但我仍坚持。我在这里解释你的评论意味着为每一行构建一系列if then语句并从中构建字符串?这是有道理的,但我认为有一种方法可以使用控件名称和标记值的组合来遍历控件。虽然您的附件就是这样,但它使用控件名称的公共部分来构建字符串:

展开 | 选择 | Wrap | 行号


我应该有点慢在今天的工作中,如果是这样,我将构建一个简单的演示来精确地说明如何做到这一点。


I have a form with five columns and 16 rows of controls. From left to right each row consists of a label, a bound and locked textbox populated from a query, two checkboxes and another unbound textbox. I''ve attached a screenshot (staff-form.jpg) of the form''s state On Load. As you can see the right checkbox as well as the right textbox are visible = false. For explanation, I will use the following as control names:

Name checkbox = chkName (located under the label Name)
Title checkbox = chkTitle (located under the label Title, currently hidden in this example)
Title textbox = txtTitle (located under the label Please Include Title, currently hidden in this example)

This form is opened by double clicking a textbox on another form and is used to select the persons who have taken part in a recent survey at a hotel. If chkName for Row 1 is ticked, chkTitle for Row 1 becomes visible. If chkTitle is ticked, the textbox under the label "Please include Title" becomes visible for Row 1. Unticking these reverses their visibility. txtTitle has a default value that can be overwritten. In the case of Tom Smith the default value for txtTitle is General Manager. In the case of Tim Allan, who works in the same Department as Bob Jones, the default value for txtTitle is "What is this person''s title?" in which case the appropriate title would be keyed in by a user. This functionality is currently working.

I would like the items selected to create a string that will be placed in the calling textbox. A partially completed form will help explain what I would like to have happen next. In the attached screenshot, Bob, Tim and Stan all participated in the survey. The user wants to show Bob and Tim''s titles but not Stan''s. Tim''s title was keyed in as Assistant Director. Please see the attached screenshot (staff-form-filled.jpg).

The resulting string for this screenshot should be:

Bob Jones, Director of Food and Beverage; Tim Allan, Assistant Director; Stan Laurel

Is this possible? Please help me understand how I can achieve this.

Thanks to all for your assistance with my project.

** Edit **
Staff-Form.jpg


Staff-Form-Filled.jpg

Attached Images
(42.6 KB, 751 views)

解决方案

  1. Iterate thru all the Controls on the Form, using strict Naming Conventions to identify Controls specific to each Row, as in:

    Expand|Select|Wrap|Line Numbers


Hi ADezii,

Arghh! I cannot seem to get my head around this but I persist. I am interpreting your comment here to mean build a series of if then statements for each row and build the string from that? That makes sense, but I thought there would be a way to loop through the controls using a combination of control names and tag values. While your attachment did just that, it used a common portion of the control name to build the string:

Expand|Select|Wrap|Line Numbers


I should be a little slow in work today, if that is the case, I''ll construct a simple Demo to precisely illustrate how this can be done.


这篇关于从表单上的选定控件创建字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆