Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何调整System.Windows.Forms.ToolBar的大小?_C#_.net_Toolbar - Fatal编程技术网

C# 如何调整System.Windows.Forms.ToolBar的大小?

C# 如何调整System.Windows.Forms.ToolBar的大小?,c#,.net,toolbar,C#,.net,Toolbar,我不喜欢面板、对接或锚。我只是简单地组合了一个工具栏控件(不是ToolStrip),似乎无法调整它的大小 System.Windows.Forms.ToolBar tb = new System.Windows.Forms.ToolBar(); // Reports 292x28 (approx) if I check width and height // Basically the width of the form and I assume a default height tb.Siz

我不喜欢面板、对接或锚。我只是简单地组合了一个工具栏控件(不是ToolStrip),似乎无法调整它的大小

System.Windows.Forms.ToolBar tb = new System.Windows.Forms.ToolBar();

// Reports 292x28 (approx) if I check width and height
// Basically the width of the form and I assume a default height
tb.Size = new System.Drawing.Size(195, 48);


// Reports 48x48, but does not actually create buttons of that size
// (It reports 48x48 because I'm retrieving 48x48 icons from a ResourceManager (resx))
tb.ButtonSize = new System.Drawing.Size(48, 48); // 
我发现使工具栏更高的最接近的方法是:

虽然已经很过时了。我不明白。工具栏按钮没有高度、宽度或大小属性

我使用的是SharpDevelop,它完全是在Vista上手工编写的,包含所有的.NET框架

编辑:

下面是我目前使用的确切代码

#region ImageList/Toolbar
ImageList toolbarImages = new ImageList();
Image wizardToolbarImage = (Bitmap) rm.GetObject("wizard");
Image optionsToolbarImage = (Bitmap) rm.GetObject("configure");
toolbarImages.Images.Add(wizardToolbarImage);
toolbarImages.Images.Add(optionsToolbarImage);      

ToolBar toolbarMain = new ToolBar();
toolbarMain.Size = new Size(195, 25); // no effect
ToolBarButton wizardToolbarButton = new ToolBarButton();
ToolBarButton optionsToolbarButton = new ToolBarButton();
wizardToolbarButton.ImageIndex = 0;
wizardToolbarButton.ToolTipText = "Wizard!";
optionsToolbarButton.ImageIndex = 1;
optionsToolbarButton.ToolTipText = "Options!";
toolbarMain.Buttons.Add(wizardToolbarButton);   
toolbarMain.Buttons.Add(optionsToolbarButton);

toolbarMain.Appearance = ToolBarAppearance.Normal;
toolbarMain.ButtonSize = new System.Drawing.Size(48, 48); // no effect
toolbarMain.ImageList = toolbarImages;
toolbarMain.ButtonClick += new ToolBarButtonClickEventHandler(toolbarMain_Click);

Controls.Add(toolbarMain);
#endregion

在我编写的几乎所有winforms应用程序中,无论语言或框架如何,工具栏都只能通过使用更大的图标来变得更高。

在我编写的几乎所有winforms应用程序中,无论语言或框架如何,只有使用更大的图标,工具栏才能变得更高。

您还可以将toolstrip放置在面板中,并将toolstrip的Dock属性设置为Fill。然后您可以根据需要调整面板的大小。

您还可以将toolstrip放入面板中,并将toolstrip的Dock属性设置为Fill。然后,您可以根据需要调整面板的大小。

您能给我一些示例代码进行比较吗?目前,我的尺寸比48x48小得多。我将在原稿中添加更多的代码,以说明我正在做的所有工作。您能给我一些示例代码进行比较吗?目前,我的尺寸比48x48小得多。我将在原稿中添加一些代码来说明我所做的一切。
System.Windows.Forms.ToolBar
System.Windows.Forms.ToolStrip
不同。请仔细阅读这个问题。@Cody Gray。你说得对,我的错。我建议的解决方案不适用于System.Windows.Forms.ToolBar.a
System.Windows.Forms.ToolBar
System.Windows.Forms.ToolStrip
不同。请仔细阅读这个问题。@Cody Gray。你说得对,我的错。我建议的解决方案不适用于System.Windows.Forms.ToolBar。