我想以编程方式用项目填充ToolStrip. toolStrip1.LayoutStyle必须是ToolStripLayoutStyle.Table.但我不能改变项目的宽度,即使我这样做,宽度恢复为默认值.
ToolStripLabel tslCheck = new ToolStripLabel("First Text"),tslSumm = new ToolStripLabel("second Text:"),tslError = new ToolStripLabel("third text:"),tslAccount = new ToolStripLabel("fourth text"),tslProvider = new ToolStripLabel("fifth text"); ToolStripTextBox tbCheck = new ToolStripTextBox(),tbAccount = new ToolStripTextBox(),tbSumm = new ToolStripTextBox(),tbError = new ToolStripTextBox(); TableLayoutSettings tsSettings; ToolStripComboBox cbProvider = new ToolStripComboBox(); protected void toolStrip1_Construct() { toolStrip1.LayoutStyle = ToolStripLayoutStyle.Table; tsSettings = toolStrip1.LayoutSettings as TableLayoutSettings; tsSettings.RowCount = 2; tsSettings.ColumnCount = 6; cbProvider.DropDownStyle = ComboBoxStyle.DropDownList; ///adding controls toolStrip1.Items.AddRange(new ToolStripItem[] { tslCheck,tbCheck,tslAccount,tbAccount,tslProvider,cbProvider,//second row tslSumm,tbSumm,tslError,tbError }); tbAccount.Width = 1000; //Width is still remains 100 cbProvider.Width = 500; //Width is still remains 121 }
但是,如果我在VisualDesigner中这样做,一切正常.
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。