0

I need to create toolstrip on the left. But toolbox have not any ToolStripContainer.

enter image description here

So I try to add manually a ToolStripContainer by coding at a design file. But a ToolStripContainer is drawn by a red cross.

 Private Sub InitializeComponent()
      Me.toolStripContainer1 = New System.Windows.Forms.ToolStripContainer()
      Me.SuspendLayout()
      Me.toolStripContainer1.Size = New System.Drawing.Size(635, 407)
      Me.toolStripContainer1.TabIndex = 0
      Me.toolStripContainer1.Text = "ToolStripContainer1"

      Me.Controls.Add(Me.toolStripContainer1)
      Me.toolStripContainer1.LeftToolStripPanel.ResumeLayout(False)
      Me.toolStripContainer1.LeftToolStripPanel.PerformLayout()
      Me.ResumeLayout(False)
      Me.PerformLayout()
 End Sub 

Can I use ToolStripContainer in .Net 5.0

FRAME_TH
  • 29
  • 7
  • What happens if you just drop a ToolStrip on the Form? -- Don't add code to the `Designer.vb` file. – Jimi Apr 23 '21 at 12:23
  • Toolstrip is find. But I cannot drag ToolStripContainer from toolbox. Because it doesn't show on the toolbox. You can see image above. – FRAME_TH Apr 23 '21 at 16:45
  • WinForms support has been beefed up considerably in .NET 5.0 from previous versions of .NET Core but it's still not complete. There are some less common things that are still not supported and this is obviously one of them. I suspect that the remaining functionality will be added in .NET 6.0 and VS 2022 so, until then, you will either have to do without or stick to .NET Framework. – jmcilhinney Apr 24 '21 at 03:25
  • For the record, the `ToolStripContainer` type does exist in .NET 5.0 but it is the designer support that doesn't. You could probably add code to your `Load` event handler to create, configure and add an instance at run time but any changes you make to the designer code file will break the designer, so it would appear. – jmcilhinney Apr 24 '21 at 03:28

1 Answers1

0

Microsoft seem to advocate continuing to use the winforms designer from .net framework - in essence you should have two projects, a .NET framework one that you do the form design in and a .NET core/5 one that you "add existing item" the forms to so they compile and work (but you design them in the other project/have two VS open)

See https://github.com/dotnet/winforms/blob/main/docs/winforms-designer.md for more info

Caius Jard
  • 72,509
  • 5
  • 49
  • 80