Click here to Skip to main content
15,880,543 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
C#
private void panel1_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                ColorDialog cd = new ColorDialog();
                if (cd.ShowDialog() == DialogResult.OK)
                {
                    this.panel3.BackColor = cd.Color;
                }
            }
        }

this is ok.
now i applyed drag and drop between two panels
C#
private void panel1_MouseDown(object sender, MouseEventArgs e)
        {
            Panel pnl = sender as Panel;
            if (pnl != null)
                pnl.DoDragDrop(pnl.BackColor, DragDropEffects.Move);
        }

        private void panel2_DragDrop(object sender, DragEventArgs e)
        {
            var data = e.Data.GetData(typeof(Color));

            if (data != null)
                ((Panel)sender).BackColor = (Color)data;
        }

        private void panel2_DragEnter(object sender, DragEventArgs e)
        {
            e.Effect = DragDropEffects.Move;
        }


this is also work fine but problem is after drag and drop code is applied panel1 mouse click is (right click) is not worked

help me.
Posted
Comments
Sergey Alexandrovich Kryukov 26-Sep-14 3:07am    
I honestly tried to track the logic and finally faced "not worked". This is not informative. What did you want to achieve and how? How is that related to your code? What did you observe in fact, exactly, and why do you feel it was wrong? And so on...
—SA
Member 10570811 26-Sep-14 3:21am    
i want if i press right click on panel1 it should be shown color dialog for color selection,then i can drag panel1 color drop to on panel2.
but after this code colpetion finally drag and drop worked but not worked panel1 right click
Member 10570811 27-Sep-14 4:05am    
anybody solve my problem
Member 10570811 27-Sep-14 5:52am    
k,i solved my self
Mukul Lad 29-Sep-14 10:59am    
Can you please share the solution?

1 solution

Hi Mukul Lad

change in panel1 mouse down events

C#
if (e.Button != MouseButtons.Right)
            {

                Panel pnl = sender as Panel;
                if (pnl != null)
                    pnl.DoDragDrop(pnl.BackColor, DragDropEffects.Move);
            }



happy coding.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900