Saturday, May 15, 2010

ACTION PANE IN VSTO 2007 (Word)

Some Simple Code Snippet Which I have learned in process of Learing Vsto .

Requirment:-

Interest
Vs2008
and Vsto


Code :-

private void ThisDocument_Startup(object sender, System.EventArgs e)
{
CreateActionPane();
}



//Initlizating the TextBox control to use in Action pane
TextBox VstoTextBox = new TextBox();
public void CreateActionPane()
{

//set text property for TextBox Control

VstoTextBox.Text = "Avinash in Action Pane User";

//Add the TextBox control to ActionPane
ActionsPane.Controls.Add(VstoTextBox);

//On document load ActionPane is shown
ActionsPane.Show();
}

OutPut:-


//Adding DatePicker in Action Pane

Code :-

//initalizing the datetimepicker control
DateTimePicker _packtdatetimer = new DateTimePicker();
public void datetimepickersample()
{
this.ActionsPane.Controls.Add(_packtdatetimer);
}



void _packtdatetimer_ValueChanged(object sender, EventArgs e)
{
//Read content and inseret the value after the paragraph
this.Content.InsertParagraphAfter();

//Insert value from the DateTimepicker select value..
this.Content.InsertAfter(_packtdatetimer.Value.ToString());
}

//Modify Internal Start Up

private void InternalStartup()
{
//value chnaged event registration in the internalStartup of the application

this._packtdatetimer.ValueChanged += new EventHandler(this._packtdatetimer_ValueChanged);

this.Startup += new System.EventHandler(ThisDocument_Startup);
this.Shutdown += new System.EventHandler(ThisDocument_Shutdown);
}



OutPut:-






No comments:

Post a Comment