在usercontrol中自动调整datagridview

时间:2010-08-11 23:24:01

标签: c# .net user-controls outlook add-in

您好我正在开发Outlook的自定义面板。 我有一个问题,我如何自动调整datagridview到userControl的宽度和高度?

这是追加: alt text http://a.imageshack.us/img180/6938/custompanel.png

编辑:

Microsoft.Office.Tools.CustomTaskPane taskPane;
        Microsoft.Office.Interop.Outlook.Application applicationObject;
        Outlook.Explorer explorer;
        TaskPaneControl tpc;
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            explorer = this.Application.ActiveExplorer();
            explorer.SelectionChange+=new Microsoft.Office.Interop.Outlook.ExplorerEvents_10_SelectionChangeEventHandler(explorer_SelectionChange);
        }

        void explorer_SelectionChange()
        {
            if (taskPane == null)
            {
                tpc=new TaskPaneControl();
                taskPane = Globals.ThisAddIn.CustomTaskPanes.Add(tpc, "Sender Details", explorer);
                taskPane.Visible = true;
                taskPane.Width = 245;
                return;
            }

            if (taskPane != null)
            {
                taskPane.Visible = true;
                taskPane.DockPosition = Office.MsoCTPDockPosition.msoCTPDockPositionBottom;
                taskPane.Height = 245;
                }
            }
        }

并添加了TaskPaneControl(userControl)

1 个答案:

答案 0 :(得分:1)

检查您是否已将Anchor属性设置为所有四个方向,或将Dock属性设置为DockStyle.Fill