Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ms access MSACCESS-如何为控件创建自定义属性_Ms Access_Properties_Controls_Customization - Fatal编程技术网

Ms access MSACCESS-如何为控件创建自定义属性

Ms access MSACCESS-如何为控件创建自定义属性,ms-access,properties,controls,customization,Ms Access,Properties,Controls,Customization,有一种方法可以为控件创建公共自定义属性,例如文本框? 我只想在文本框中添加边框颜色,如下所示: public property Empty(ValX as Boolean) if ValX = true then Screen.ActiveControl.BorderWidth = 10 Screen.ActiveControl.BorderColor = RGB(255, 0, 0) else Screen.ActiveControl.BorderWidth = 0 Screen.A

有一种方法可以为控件创建公共自定义属性,例如文本框? 我只想在文本框中添加边框颜色,如下所示:

public property Empty(ValX as Boolean)

if ValX = true then
 Screen.ActiveControl.BorderWidth = 10
 Screen.ActiveControl.BorderColor = RGB(255, 0, 0)
else
 Screen.ActiveControl.BorderWidth = 0
 Screen.ActiveControl.BorderColor = RGB(0, 0, 0)
end if

end property
text1.Empty=true
MyEmpty Text1, True
所以我可以这样使用它:

public property Empty(ValX as Boolean)

if ValX = true then
 Screen.ActiveControl.BorderWidth = 10
 Screen.ActiveControl.BorderColor = RGB(255, 0, 0)
else
 Screen.ActiveControl.BorderWidth = 0
 Screen.ActiveControl.BorderColor = RGB(0, 0, 0)
end if

end property
text1.Empty=true
MyEmpty Text1, True
这只是我需要的一个例子。。
提前感谢

您可以通过继承基本控件来“重载”或创建自己的控件

你能得到/做的最好的

这将有助于:

Public Sub MyEmpty(c As Control, Highlight As Boolean)

  If Highlight Then
     c.BorderWidth = 6
     c.BorderColor = RGB(255, 0, 0)
  Else
     c.BorderWith = 1
     c.BorderColor = RGB(0, 0, 0)
  End If

End Sub
那么,在形式代码中?你会这样说:

public property Empty(ValX as Boolean)

if ValX = true then
 Screen.ActiveControl.BorderWidth = 10
 Screen.ActiveControl.BorderColor = RGB(255, 0, 0)
else
 Screen.ActiveControl.BorderWidth = 0
 Screen.ActiveControl.BorderColor = RGB(0, 0, 0)
end if

end property
text1.Empty=true
MyEmpty Text1, True
作为参考? 边框宽度为0到6个允许值。 但是上面的颜色应该很好用

因此,不需要太多的代码,也不需要太多的键入-但是如果您可以创建一个控件的自定义属性,那么只需要稍微多一点-但它不是一个选项。以上功能应该可以正常工作,因此您不必依赖screen.active