复制按钮的问题 [英] problem with copying buttons

查看:85
本文介绍了复制按钮的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows窗体应用程序(在VISUAL STUDIO 2008上完成).我利用流程布局面板和按钮.复制并粘贴后,按钮上出现问题.
双击按钮后,它将导致另一种形式,但是我不知道双击编辑按钮的原始副本后会弹出多少次(例如frm.showdialog())粘贴到面板上.很好,我尝试在粘贴后将复制的按钮名称设置为新名称,但是仍然会发生此问题.但是,如果我通过上下文菜单并选择``编辑'',它将很好用(窗体仅打开一次).
好吧,我将编辑工具条中的代码放入条件

I have a windows form application(done on VISUAL STUDIO 2008 ). I make use of a flow layout panel and buttons. I have a problem on the buttons after copying and pasting it.
after double clicking the buttons , it''ll lead to another form , but I got no idea how come after double-clicking to edit the original copy of the button it pops out the number of times(eg frm.showdialog()) I pasted onto the panel. well I tried setting the copied button name to a new name after getting pasted but that problem still happens.However if I go through the context menu and select edit it''ll work fine (form opens only once).
well I place the code from the edit toolstrip into the condition

if(e.clicks==2)


这是错误的. (在运行期间)

父母与子女的关系有关系吗?
有人知道这里出什么问题吗?
部分代码
如果我没有清楚解释,请原谅我
像这样


which is wrong. (DURING RUN-TIME)

Is there something to do with parent and child relation?
anyone knows whats the problem here?
part of the code
pardon me if i didnt explain clearly
it goes something like this

public void newbutton_MouseDown(object sender, MouseEventArgs e)

 {
            prebutton = (Button)sender;
            Point p = new Point(e.X, e.Y);

                if (e.Button == MouseButtons.Right && count < 2)
                    cm_rightclick.Show(prebutton, p);//user supposedly right click ,then click onto edit to edit the moves on the button

             if (e.Button == MouseButtons.Left && e.Clicks == 2)
             editToolStripMenuItem_Click(sender,e);

 }
public void editToolStripMenuItem_Click(object sender, EventArgs e)
  {
            bool bFound = false;

            //Initiating an instance of Move Category.cs form
            moveCatergory frm = new moveCatergory();
            //Using the FindSingleMovement FUNCTION
            SingleMovement sm = FindSingleMovement(ref  bFound);
            frm.sm =  sm;
           frm.ShowDialog(); //when it comes here , dialog appears more than once for the copied button and the original button that is being copied
            for (int i = 0; i < allMovements.Count; i++)
            {
                if (sm.button_action == allMovements[i].button_action)
                    break;

            }
            //FOR LOOP used for checking which dancestep is selected
            int k = 0;

            //After the checking is done, the selected dancestep list will be removed and the edited dancestep will be added
            if (k < allMovements.Count)
            {
                allMovements.Remove(allMovements[k]);
                frm.sm.button_action.Text = frm.sm.dance_action.nametxt;
                allMovements.Insert(k, frm.sm);
            }

        }



有人知道这里出什么问题吗?



anyone knows what''s the problem here?

推荐答案

似乎您的 editToolStripMenuItem_Click 事件正在被触发从按钮调用两次.您可以看几件事:

1.)由于该按钮将在每次单击鼠标按钮时触发所有鼠标/单击事件,因此您可以检查鼠标单击生命中是否有多个事件调用了 editToolStripMenuItem_Click 循环(MouseDown,MouseClick,MouseUp,Click).

2.)检查以确保 newbutton_MouseDown 与该钩子的MouseDown事件的钩接不超过一次,否则将被视为该事件的单独使用者,并且每次单击都会被触发两次.
It seems that your editToolStripMenuItem_Click event is being triggered twice when called from the button. A couple things you can look at:

1.) Since the button will fire off all mouse/click events each time the mouse button is clicked, you might check to see if the editToolStripMenuItem_Click is being called from more than one event in the mouse clicking life cycle(MouseDown, MouseClick, MouseUp, Click).

2.) Check to ensure that the newbutton_MouseDown is not hooked more than once to the button''s MouseDown event or it will be treated as a separate consumer of the event and will get triggered twice during each click.


这篇关于复制按钮的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆