为MS Access 2010创建自定义控件 [英] Creating Custom Controls for ms access 2010

查看:100
本文介绍了为MS Access 2010创建自定义控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用.Net语言创建自定义控件以用于MS Access 2010?我有一个程序正在使用子窗体来尝试模拟控件,但它确实不能很好地工作。如果我能够使用C#或VB.Net或其他任何东西创建自定义控件并将其导入到Access,那么我的生活会容易得多。

Is there a way to create custom controls in a .Net Language for use in MS Access 2010? I have a program that is using subforms to attempt to emulate a control but it really is not working very well. If I was able to create a custom control in say C# or VB.Net or really anything and import it to Access My life would be much easier. Is this possible?

推荐答案

虽然理论上可以在.NET中创建一个可以在MS Access中使用的控件,但是它可以这也是非常不切实际的,因为有很多东西无法正常工作。

While it is theoretically possible to create a control in .NET that can be used in MS Access, it is also very impractical because there are so many things that do not work.

以下是我尝试时遇到的一些问题:

Here's some of the problems I ran into when I tried it:


  • 我从没绑定过工作。换句话说,我无法以使其可以在MS Access中使用的方式公开.NET的本机绑定。

  • 我无法调整控件的大小。在Access中更改控件的大小时,仅更改控件放置在其上的设计图的大小。它对控件的大小没有影响。

  • .NET ActiveX控件将打包在.DLL文件中,而不是.OCX文件中。您必须使用RegAsm工具来注册.DLL文件。

  • 您必须下载并安装Microsoft的Interop Form的Toolkit 2.1,才能创建COM互操作控件。

  • 将.Net控件的属性,方法和事件暴露给COM接口是一个相当手动和费力的过程。例如,组合框为值属性,但不会自动映射到ActiveX控件的.value属性。实际上,我找不到映射两者的任何方法,因此我不得不创建一个单独的具有不同名称的value属性,这对于使用该控件的程序员而言非常不直观。典型的手动绑定最终看起来像这样:Me!MyFieldName = Me.ActiveXControl.MyValue

  • 在.Net中使用COM调用包装器编写内容是否是ActiveX有点愚蠢控制与否。您必须知道如何编写.NET代码,以便VBA中的Intellisense可以正确显示属性,方法和事件。这涉及编写一个公共接口,使用委托,我什至不记得所有这些。只需说它很复杂即可。

  • I never did get binding to work. In other words, I couldn't expose .NET's native binding in a way that made it usable in MS Access.
  • I couldn't get the control to resize. When you change the size of the control from within Access, you are only change the size of the "design surface" upon which the control is placed. It has no effect on the size of the control.
  • .NET ActiveX controls will be packaged in a .DLL file, not an .OCX file. You have to use the RegAsm tool to register the .DLL file.
  • You have to download and install Microsoft's Interop Form's Toolkit 2.1 to be able to create a COM interop control.
  • Exposing .Net control properties, methods, and events to a COM interface is a fairly manual and laborious process. For example, the combobox as a "value" property but it is not automatically mapped to an ActiveX control's .value property. In fact, I couldn't find any way to map the two so I had to actually create a separate value property with a different name which is far from intuitive for the programmer using the control. A typical manual "binding" would end up looking something like this: Me!MyFieldName = Me.ActiveXControl.MyValue
  • Writing in COM callable wrapper in .Net is a little goofy whether it's an ActiveX control or not. You have to know how to write your .NET code so that the properties, methods, and events will show up properly with Intellisense in VBA. This involves writing a public interface, using delegates, and I don't even remember what all. Suffice it to say that it's complicated.

最后,我开始怀疑自己是否没有真正地努力做一些不可能的事情。并想知道仅使用.NET进行所有操作并完全转储Access是否会更好。不幸的是,今天我仍在开发Access,但我们正在认真考虑在不久的将来转向.NET。

At the end of it all I started to wonder if I wasn't working real hard on doing something that was impossible. And wondered if it wouldn't be better just to use .NET for everything and dump Access completely. Unfortunately, today I'm still developing in Access but we are seriously looking at moving to .NET in the near future.

您还可以在这里看到我参与过的另一个相关问题:
http://social.msdn.microsoft.com/Forums/ zh-CN / accessdev / thread / 06867384-9e1f-486d-982a-6bbb0f40848d /#5b27805f-3a95-4bbd-a50e-3de06e199490

You can see another other related question here that I contributed to: http://social.msdn.microsoft.com/Forums/en-US/accessdev/thread/06867384-9e1f-486d-982a-6bbb0f40848d/#5b27805f-3a95-4bbd-a50e-3de06e199490

这篇关于为MS Access 2010创建自定义控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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