1

パネル、ドッキング、またはアンカーを気にしたことはありません。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.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); // 

ツールバーを高くするのに最も近いものは次のとおりです。

http://bytes.com/topic/c-sharp/answers/241614-ching-height-toolbar-button

それはかなり時代遅れですが。そして、私はそれを理解していませんでした。ToolBarButtons には、Height、Width、または Size プロパティがありません。

私は、すべての .NET フレームワークを使用して、Vista で完全に手作業でコーディングし、SharpDevelop を使用しています。

編集:

これが私が現在使用している正確なコードです。

#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
4

2 に答える 2

0

ツールストリップを Panel 内に配置して、ツール ストリップの Dock プロパティを Fill に設定することもできます。次に、必要なサイズにパネルのサイズを変更できます。

于 2011-04-15T22:06:14.770 に答える