是否有可能举办一个Microsoft Access格式的净Windows窗体里面?有可能、窗体、里面、格式

2023-09-04 07:44:24 作者:态度决定高度

我问是否可以举办一个Microsoft Access窗体。净表单中。

I am asking if it is possible to host a Microsoft Access form inside a .Net form.

没有我还没有疯,我们维持一个庞大的系统,完全用VBA写的人谁不知道很多VBA的尝试使用Microsoft Access作为一个IDE。它基本上是成千上万的意大利面条code线,虽然我们愿意放弃它,并从头开始,这是不是一种选择。

No I haven't gone mad, we are maintaining a massive system written entirely in VBA by somebody who didn't know a lot of VBA attempting to use Microsoft Access as an IDE. It's basically thousands of lines of spaghetti code and while we would love to scrap it and start from scratch, this is not an option.

因此​​,我们努力改善这有什么,在这种特殊的情况这将是非常有益的,如果我们能以某种方式举办一个.net Windows窗体里面的Microsoft Access形式,我们可以从.NET中的专有的硬件多互动更有效地比我们可以从VB6。

We are therefore trying to improve what is there, and in this particular scenario it would be really helpful if we could somehow host the Microsoft Access forms inside a .Net Windows Form as we can interact with the proprietary hardware from .Net much more effectively than we can from VB6.

我们目前拥有的计算机旁边的用户可以在任何时间打开许多MS-Access数据库上运行的.NET应用程序,以及.NET应用程序进行交互这些使用MS接入互操作有不同程度的成功。这是因为它采用表格的标题和文件名/位置,以获得一个句柄对数据库做它需要做的,也依赖于用户不会干扰/关闭应用/数据库移动到桌面等,这是一个有点乱。

We currently have a .Net application that runs on the computer alongside the many MS-Access databases that the users have open at any one time, and the .Net application interacts with these using MS Access Interop with varying degrees of success. This is because it uses form titles and filenames/locations to get a handle on the database to do what it needs to do, and also relies on the user not interfering/switching off the application/moving the databases to their desktops etc. It's a bit of a mess.

所以,我问是否有可能一个.net的Windows窗体中以某种方式举办的Microsoft Access的形式,通过可能增加窗体本身作为控制或子窗体,在某种程度上,这将使我直接访问所有从净形式?

Therefore, I am asking if it is possible to somehow host a Microsoft Access form inside a .Net Windows form, by maybe adding the form itself as a control or a subform, in a way that would give me direct access to all of the controls on the form from .Net?

推荐答案

由于短以外,我们开始之前,如果...

As a short aside, before we begin, if...

你问怎么没有了镀铬的应用程序托管只是一个单一的接入形式;和 您正在使用Access的运行时版本

...你正在运行相抵触的Access运行时EULA的:

...you're running afoul of the Access Runtime EULA:

2。其他许可要求和/或使用权利。

...

二。分发要求。对于任何可分发code分发,你必须......

ii. Distribution Requirements. For any Distributable Code you distribute, you must...

  在保持包含技术支持的Microsoft Office Access被用户观看显示在您的用户界面在任何时候声明状态栏;   

这可能付费阅读的最终用户许可协议(它不是那么长),只是看你能不能使用什么样的访问运行库。

It might pay to read the EULA (it's not that long) just to see what you can and can't use the Access Runtime for.

所以,我问是否有可能一个.net的Windows窗体中以某种方式举办的Microsoft Access的形式,通过可能增加窗体本身作为控制或子窗体,在某种程度上,这将使我直接访问所有从净形式?

Therefore, I am asking if it is possible to somehow host a Microsoft Access form inside a .Net Windows form, by maybe adding the form itself as a control or a subform, in a way that would give me direct access to all of the controls on the form from .Net?

您可能要反转的情况:运行内访问您的.NET code。

You might want to invert the scenario: run your .NET code inside Access.

这基本上限嗣继承创建一个共享加载项在Visual Studio中的Access可以加载和处理。从那里,你可以连线了控制和事件。

This basically entails creating a Shared Add-in in Visual Studio that Access can load and manipulate. From there you can wire up controls and events.

public void HookupControls(
   Access.CommandButtonClass button,
   Access.ListBoxClass listBox,
   Access.TextBoxClass textBox1,
   Access.TextBoxClass textBox2)
{
    fillProductsButton = button;
    fillProductsButton.Click += 
        new Access.DispCommandButtonEvents_ClickEventHandler(
        fillProductsButton_Click);
    fillProductsButton.OnClick = "[Event Procedure]";

    unitPriceTextBox = textBox1;
    quantityTextBox = textBox2;
}

这需要从你的访问应用程序的一些合作:

It requires some co-operation from your Access application:

With COMAddIns("SharedAddIn.Connect")
    ''// Make sure the COM add-in is loaded.
    .Connect = True

    ''// Hook up the desired objects.
    .Object.HookupControls Me.fillProductsButton, Me.productsListBox, _
        Me.unitPriceTextBox, Me.quantityTextBox
End With

免责声明:我想尝试这一点,但在Visual Studio 2012似乎创建共享外接缺少的能力。情况因人而异。有引用共享的加载项的文档中< /一>,但是,所以也许我想的东西或功能在VS 2012 RC。

Disclaimer: I wanted to try this but in Visual Studio 2012 it seems the ability to create a Shared Add-in is missing. YMMV. There's references to Shared Add-ins in the documentation, however, so perhaps I'm missing something or the functionality isn't in VS 2012 RC.