Creating Custom Controls for ms access 2010

天涯浪子 提交于 2019-12-25 05:14:20

问题


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?


回答1:


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:

  • 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.

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.

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



来源:https://stackoverflow.com/questions/12011901/creating-custom-controls-for-ms-access-2010

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!