Search code examples
c#toolstrippanel

ToolStrip Wont dragged when added to ToolStripPanel


I'm following the video on YouTube below

Using ToolStripPanel Control to work with an Mdi Form

It's in VB .NET, I try to use in C#. Here is my code :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Cyan_Pembuat_Soal
{
    public partial class Form1 : Form
    {
        ToolStripPanel Topside;
        ToolStripPanel Downside;
        MenuStrip Menu;
        StatusStrip Status;
        ToolStrip a;
        public Form1()
        {
            InitializeComponent();
            Topside = new ToolStripPanel();
            Downside = new ToolStripPanel();
            Menu = new MenuStrip();
            Menu.Dock = DockStyle.Top;
            Status = new StatusStrip();
            Status.Dock = DockStyle.Bottom;
            this.Controls.Add(Topside);
            this.Controls.Add(Downside);
            this.Controls.Add(Menu);
            this.Controls.Add(Status);
            Topside.Dock = DockStyle.Top;
            Downside.Dock = DockStyle.Bottom;
            a = new ToolStrip();
            a.Dock = DockStyle.Top;
            a.Items.Add("Test");
            Topside.Controls.Add(a);
        }
    }
}

There are no errors. But if I try to drag the ToolStrip (variable a), it won't move as in video. Help me what's wrong and how to fix that.


Solution

  • I checked my solution and I found that I created a class with same name. It would cause unwanted behavior like that because the original class is obscured with that. When I deleted that class, it work correctly.