简体   繁体   English

不包含“表格”的定义? Outlook加载项

[英]does not contain a definition for 'Form' ? Outlook Add-in

Recently I' am working on an add-in with c# for Outlook 2010 in Visual Studio 2012 . 最近,我正在Visual Studio 2012中为Outlook 2010使用c#加载项。 I developed a custom Form region which contains simple textboxes and a button. 我开发了一个自定义Form区域,其中包含简单的文本框和一个按钮。 In Button_click method I' am taking an error (error Code : error CS0117) and I couldn't figure out why ? 在Button_click方法中,我遇到一个错误(错误代码:error CS0117),我不知道为什么吗? I am really new of this environment :) any way here it is my problem. 我对这种环境真的很陌生:)无论如何,这是我的问题。 (if you need more code to solve just let me know) (如果您需要更多代码来解决,请告诉我)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Office = Microsoft.Office.Core;
using Outlook = Microsoft.Office.Interop.Outlook;
using MSForms = Microsoft.Vbe.Interop.Forms;

. . .

private void button1_Click(object sender, EventArgs e)
        {
        // save button
        MSForms.UserForm userForm = (MSForms.UserForm) FormRegion1.Form;
        MSForms.Controls formControls = userForm.Controls;

        Outlook.OlkTextBox ad =
           (Outlook.OlkTextBox)formControls.Item("ad");
        string cariad = ad.Text;

        Outlook.OlkTextBox adres =
          (Outlook.OlkTextBox)formControls.Item("adres");
        string cariadres = adres.Text;

        Outlook.OlkTextBox vergid =
          (Outlook.OlkTextBox)formControls.Item("vergid");
        string carivergid = vergid.Text;

. . .

* MSForms.UserForm userForm = (MSForms.UserForm) in line FormRegion1.Form "Form" is not recognized. *无法识别FormRegion1.Form行“ Form”中的MSForms.UserForm userForm = (MSForms.UserForm) And error says 错误说

" error CS0117: 'OutlookAddIn2.FormRegion1' does not contain a definition for 'Form'". “错误CS0117:“ OutlookAddIn2.FormRegion1”不包含“表单”的定义”。

Thanks a lot. 非常感谢。

I solved that problem with not using Forms:) Simply, I just typed 我不使用Forms就解决了这个问题:)简单来说,我只是输入

 this.TextBoxName.Text;

to reach the text of the textBox. 到达textBox的文本。 Thanks any way. 不管怎么说,还是要谢谢你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM