Visual Studio 2008 による the 2007 Microsoft Office sysrem Word コンテンツコントロールの利用
このデモでは、Visual Studio 2008 (旧称:Visual Studio Codename “Orcas”) の Beta 2 を使用しています。このデモで使用されているクラス、メソッドなどについては今後変更される可能性がありますのでご注意ください。 |
このデモの内容 |
ここでは、Visual Studio 2008 に実装された VSTO (Visual Studio tools for the 2007 Microsoft Office system) を用い、Word コンテンツコントロールを使用したアプリケーションの開発手法をご紹介します。
デモでご紹介しているソースコード |
【ThisDocument.cs】
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.VisualStudio.Tools.Applications.Runtime;
using Office = Microsoft.Office.Core;
using Word = Microsoft.Office.Interop.Word;
namespace Demo_WordContent
{
public partial class ThisDocument
{
private void ThisDocument_Startup(object sender, System.EventArgs e)
{
// TODO: Delete this line of code to remove the default AutoFill for 'catDataSet.Categories'.
if (this.NeedsFill("catDataSet"))
{
this.categoriesTableAdapter.Fill(this.catDataSet.Categories);
}
UserControl1 myControl = new UserControl1();
this.ActionsPane.Controls.Add(myControl);
}
private void ThisDocument_Shutdown(object sender, System.EventArgs e)
{
}
#region VSTO Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Shutdown += new System.EventHandler(this.ThisDocument_Shutdown);
this.Startup += new System.EventHandler(this.ThisDocument_Startup);
}
#endregion
}
}
【UserControl1.cs】
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Demo_WordContent
{
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
Globals.ThisDocument.categoriesBindingSource.MoveNext();
}
private void button1_Click(object sender, EventArgs e)
{
Globals.ThisDocument.categoriesBindingSource.MovePrevious();
}
}
}
![](images/cc707258.top(ja-jp, MSDN.10).gif)ページのトップへ