质疑微软.net中Toolbar类库的设计思路

Dream_soft 2002-03-20 09:59:15
近来.net呼声很高,闲来无事,把玩了一番。对微软Toolbar的设计思路很不解,不知为何Toolbar中只能容纳ToolbarButton?为什么不能拖动?在我的设想中,该是可以容纳所有控件的,比如Combox等。同时,为什么没有提供Action这个类呢?要知道,在Delphi和Java中,这可是很好用的功能呢。
studio.net自已的工具条很有特色,可我怀疑并不是使用的Toolbar:类库中的Toolbar的确太差了。以微软的实力,又有前人的东西可以借鉴,该是不会有这种失误的。
所以我想,也许微软会有别的方法和考虑,请知道的朋友教我,谢谢!
...全文
40 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Dream_soft 2002-03-21
  • 打赏
  • 举报
回复
对不起了,两位。我又试了一次,事实上,用手工的方法,是可以加入的。
谢谢两位的帮助:)

又:工具条的拖动,请问有没有直接的支持呢?
Dream_soft 2002-03-21
  • 打赏
  • 举报
回复
To Michael_Jackson:
您说的情况,也同sam1111兄说的一样,两者只是位置上的重叠罢了。强行用手工写入如下代码将Button2加入Button1中:

this.button1.SuspendLayout();
this.button1.Controls.AddRange(new System.Windows.Forms.Control[] { this.button2});

事实上,Button2并不能得到显示。当然,可能是我代码有错误,如是,请您指正。
Dream_soft 2002-03-21
  • 打赏
  • 举报
回复
To nsam1111:
这是直接放ComboBox在ToolBar上生成的代码,我想,这种情况只是在位置上ComboBox和ToolBar重叠在一起了,而事实上,拥有ComboBox的,还是Form吧?

private void InitializeComponent()
{
this.toolBar1 = new System.Windows.Forms.ToolBar();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// toolBar1
//
this.toolBar1.DropDownArrows = true;
this.toolBar1.Name = "toolBar1";
this.toolBar1.ShowToolTips = true;
this.toolBar1.Size = new System.Drawing.Size(552, 39);
this.toolBar1.TabIndex = 2;
//
// comboBox1
//
this.comboBox1.Location = new System.Drawing.Point(216, 8);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(112, 20);
this.comboBox1.TabIndex = 3;
this.comboBox1.Text = "comboBox1";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(552, 413);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.comboBox1,
this.toolBar1});
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

}

Michael_Jackson 2002-03-20
  • 打赏
  • 举报
回复
呵呵,怎么样都行的!可以在Button里再放个Button,也可以在Splitter控件中放Button都行!用Add方法。自已研究一下! :)
sam1111 2002-03-20
  • 打赏
  • 举报
回复
可以放ComboBox呀,将ComboBox直接放在ToolBar上就行了,不用从属性里添加。

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧