当前位置:编程学习 > C#/ASP.NET >>

【求助】MDI窗口右键删除指定的控件问题

Label newLabel = new Label();
newLabel.ContextMenuStrip = this.contextMenuStrip1;
newLabel.MouseDown += new MouseEventHandler(newControl_MouseDown);

        void newControl_MouseDown(object sender, MouseEventArgs e)//事件中增加鼠标点击就聚焦到该控件
        {
            if (sender.GetType() == typeof(Button))
            {
                Button currentButton =(Button)sender;
                if (null == currentButton)
                    return;
                currentButton.Focus();
            }
            else
            {
                Label currentLabel = (Label)sender;
                if (null == currentLabel)
                    return;
                currentLabel.Focus();
            }
        }


删除的按钮的代码是
        private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)//删除获得焦点的控件
        {
            Form currentMdiForm = this.ActiveMdiChild;
            this.Controls.Remove(currentMdiForm.ActiveControl);
        }

调试的时候没有反应 不能删除MdI窗口的选中的控件 不知道为何 ?请各位指教  --------------------编程问答-------------------- 顶~~~~~~~~~~~~~~~~ --------------------编程问答-------------------- 软件不做了 放弃了 
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,