提问人:artodoro 提问时间:11/9/2023 最后编辑:artodoro 更新时间:11/9/2023 访问量:50
无法调整 UserControl 的大小
Cant resize UserControl
问:
我正在尝试为VBIDE编写一个简单的扩展。我的问题是UserControl(WinForm)不会拉伸到可停靠窗口的宽度,并且在调整窗口大小时不会调整大小。
Control.Designer.cs:
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.commandLineBox = new System.Windows.Forms.RichTextBox();
this.resultLabel = new System.Windows.Forms.Label();
this.resultToolTip = new System.Windows.Forms.ToolTip(this.components);
this.SuspendLayout();
//
// commandLineBox
//
this.commandLineBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.commandLineBox.Dock = System.Windows.Forms.DockStyle.Top;
this.commandLineBox.Location = new System.Drawing.Point(0, 0);
this.commandLineBox.Name = "commandLineBox";
this.commandLineBox.TabIndex = 0;
this.commandLineBox.Text = "";
this.commandLineBox.Enter += new System.EventHandler(this.commandLineBox_Enter);
this.commandLineBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.commandLineBox_KeyDown);
//
// resultLabel
//
this.resultLabel.AutoSize = true;
this.resultLabel.Dock = System.Windows.Forms.DockStyle.Top;
this.resultLabel.Location = new System.Drawing.Point(0, 38);
this.resultLabel.Name = "resultLabel";
this.resultLabel.TabIndex = 1;
this.resultLabel.TextChanged += new System.EventHandler(this.resultLabel_TextChanged);
//
// Terminal
//
this.Controls.Add(this.resultLabel);
this.Controls.Add(this.commandLineBox);
this.Name = "Terminal";
this.Dock = System.Windows.Forms.DockStyle.Fill;
this.ResumeLayout(false);
}
我试图在显示窗口后更改为在课堂上,但是:control.Dock
DockStyle.Fill
Extension
control = null
public class Extension : IDTExtensibility2
{
private VBEWrapper _wrapper;
private VB.AddIn _addin;
private VB.Window terminalWindow;
public void OnConnection(object Application, ext_ConnectMode ConnectMode, object AddInInst, ref Array custom)
{
_wrapper = VBEWrapper.GetInstance((VB.VBE)Application);
_addin = (VB.AddIn)AddInInst;
switch (ConnectMode)
{
case ext_ConnectMode.ext_cm_AfterStartup:
CreateWindow();
break;
case ext_ConnectMode.ext_cm_Startup:
break;
}
}
private void CreateWindow()
{
Termin control = null;
try
{
terminalWindow = _wrapper.VBE.Windows.CreateToolWindow(
_addin,
"VBATerminal.Terminal",
"Terminal",
"EE7EEC61-E607-44B8-830F-34839672CD30",
control);
terminalWindow.Visible = true;
const int defaultWidth = 350;
const int defaultHeight = 200;
if (terminalWindow.Width < defaultWidth)
{
terminalWindow.Width = defaultWidth;
}
if (terminalWindow.Height < defaultHeight)
{
terminalWindow.Height = defaultHeight;
}
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
}
//
}
}
编辑:
这是一个变体,它应该(我猜)分配一个值来控制,但它也没有这样做:
object control = null
terminalWindow = _wrapper.VBE.Windows.CreateToolWindow(
_addin,
"VBATerminal.Terminal",
"terminal",
"EE7EEC61-E607-44B8-830F-34839672CD30",
ref control);
我做错了什么?
答: 暂无答案
评论
CreateToolWindow
CreateToolWindow