Evento CustomTaskPane.DockPositionChanged (sistema de 2007)
Ocorre quando o usuário altera a posição de encaixar do personalizado tarefa painel, ou quando o código altera o valor do DockPosition propriedade.
Namespace: Microsoft.Office.Tools
Assembly: Microsoft.Office.Tools.Common.v9.0 (em Microsoft.Office.Tools.Common.v9.0.dll)
Sintaxe
Public Event DockPositionChanged As EventHandler
Dim instance As CustomTaskPane
Dim handler As EventHandler
AddHandler instance.DockPositionChanged, handler
public event EventHandler DockPositionChanged
Exemplos
O exemplo de código a seguir demonstra um manipulador de eventos para o DockPositionChanged evento. Esse manipulador de eventos altera a disposição vertical ou horizontal dos controles no painel de tarefas por modificar o FlowDirection propriedade de um FlowLayoutPanel no painel de tarefas. Este exemplo de código assume que o tarefa painel contém um UserControl chamada MyUserControle o UserControl contém um FlowLayoutPanel chamada FlowPanel. Este exemplo faz parte de um exemplo maior fornecido para o CustomTaskPane classe.
PrivateSub myCustomTaskPane_DockPositionChanged(ByVal sender AsObject, _
ByVal e As EventArgs) Handles myCustomTaskPane.DockPositionChanged
Dim taskPane As Microsoft.Office.Tools.CustomTaskPane = _
TryCast(sender, Microsoft.Office.Tools.CustomTaskPane)
If taskPane IsNotNothingThen
' Adjust sizes of user control and flow panel to fit current task pane size.Dim userControl As MyUserControl = TryCast(taskPane.Control, MyUserControl)
Dim paneSize As System.Drawing.Size = _
New System.Drawing.Size(taskPane.Width, taskPane.Height)
userControl.Size = paneSize
userControl.FlowPanel.Size = paneSize
' Adjust flow direction of controls on the task pane.If taskPane.DockPosition = _
Office.MsoCTPDockPosition.msoCTPDockPositionTop Or _
taskPane.DockPosition = _
Office.MsoCTPDockPosition.msoCTPDockPositionBottom Then
userControl.FlowPanel.FlowDirection = _
System.Windows.Forms.FlowDirection.LeftToRight
Else
userControl.FlowPanel.FlowDirection = _
System.Windows.Forms.FlowDirection.TopDown
EndIfEndIfEndSub
privatevoid myCustomTaskPane_DockPositionChanged(object sender, EventArgs e)
{
Microsoft.Office.Tools.CustomTaskPane taskPane =
sender as Microsoft.Office.Tools.CustomTaskPane;
if (taskPane != null)
{
// Adjust sizes of user control and flow panel to fit current task pane size.
MyUserControl userControl = taskPane.Control as MyUserControl;
System.Drawing.Size paneSize = new System.Drawing.Size(taskPane.Width, taskPane.Height);
userControl.Size = paneSize;
userControl.FlowPanel.Size = paneSize;
// Adjust flow direction of controls on the task pane.if (taskPane.DockPosition ==
Office.MsoCTPDockPosition.msoCTPDockPositionTop ||
taskPane.DockPosition ==
Office.MsoCTPDockPosition.msoCTPDockPositionBottom)
{
userControl.FlowPanel.FlowDirection =
System.Windows.Forms.FlowDirection.LeftToRight;
}
else
{
userControl.FlowPanel.FlowDirection =
System.Windows.Forms.FlowDirection.TopDown;
}
}
}
Permissões
- Confiança total para o chamador imediato. O membro não pode ser usado por código parcialmente confiável. Para obter mais informações, consulte Usando bibliotecas de códigos parcialmente Confiável.