问题
单项选择题
假设在一个表单里有一个文本框Text1和一个命令按钮组CommamdGroup1。命令按钮组是一个容器对象,其中包含Command1和Commsnd2两个命令按钮。如果要在Command1命令按钮的某个方法中访问文本框的Value属性值,正确的语句是( )。
A) This.ThisForm.Text1.Value
B) ThisParent.Parent.Text1.Value
C) ParentParent.Text1.Value
D) ThisParent.Text1.Value
答案
参考答案:B
解析: 本题要求在Command1的某个方法中访问文本框的Value属性值,应该选B)选项This.Parent.Parent.Text1.Value,其中This表示当前对象Command1;This.Parent表示当前对象Command1的父对象,即命令按钮组CommandGroup1;ThisParent.Parent表示命令按钮组的父对象,即表单;This.ParentParent.Text1.Value表示通过命令按钮Command1访问表单中的文本框的值。