Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8857329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:33:47+00:00 2026-06-14T14:33:47+00:00

i have two panel in ma form. panel1 with button1 on it at location

  • 0

i have two panel in ma form. panel1 with button1 on it at location let say x:10,y:10 and panel2 with button 2 on it at location x:10,y:10.

what actually button1 do:- it hide panel1 and shows panel2 at the same location.

but whenever i click on button1 twice after completion its process it fire button2 click event,

plz help me ASAP

hope below link will demonstrate my prob clearly

http://www.youtube.com/watch?v=bpojl4XMweo&feature=g-upl

EDIT:

Code used so far

void hidepanel()
{
    panel1.Visible = false;
    panel2.Visible = false;
}

private void Form1_Load(object sender, EventArgs e)
{
    hidepanel();
    panel1.Visible = true;
    panel2.Location = new Point(262,19);
    panel1.Location = new Point(0, 0);
}

private void button1_Click(object sender, EventArgs e)
{
    hidepanel();
    panel2.Location = new Point(0, 0);
    panel2.Visible = true;
}

private void button2_Click(object sender, EventArgs e)
{
    MessageBox.Show("2");
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T14:33:48+00:00Added an answer on June 14, 2026 at 2:33 pm

    just add some logic to hide/unhide enable/disable the oposite components. Just like this:

        private void button1_Click(object sender, EventArgs e)
        {
            addLog("Button 1 clicked");
            button1.Enabled = false;
            button2.Enabled = false;
            panel1.Visible = false;
            panel2.Visible = true;
            button2.Enabled = true;
        }
    
        private void button2_Click(object sender, EventArgs e)
        {
            addLog("Button 2 clicked");
            button2.Enabled = false;
            panel2.Visible = false;
            panel1.Visible = true;
            button1.Enabled = true;
    
        }
    

    works for me like a charme:

    enter image description here enter image description here

    regards

    Josef

    EDIT:
    Now, I see the problem, the mouse clicks are enqueued into windows message queue and will fire the click event on button2 although you clicked on a disabled/hidden button1.

    I found the solution here: Ignoring queued mouse events

    and changed the code to:

            public static void ClearMouseClickQueue()
        {
            win32msg.NativeMessage message;
            while (win32msg.PeekMessage(out message, IntPtr.Zero, (uint)win32msg.WM.WM_MOUSEFIRST, (uint)win32msg.WM.WM_MOUSELAST, 1))
            {
            }
        }
        ...
                private void button1_Click_1(object sender, EventArgs e)
        {
            addLog("Button 1 clicked");
            button1.Enabled = false;
            button2.Enabled = false;
            panel1.Visible = false;
            System.Threading.Thread.Sleep(2000);
            ClearMouseClickQueue();
            panel2.Visible = true;
            button2.Enabled = true;
        }
    

    where PeekMessage etc is defined another class:

        using System;
    
        using System.Collections.Generic;
        using System.Text;
    
        using System.Runtime.InteropServices;
    
        namespace PanelTest
        {
            public static class win32msg
            {
                [DllImport("coredll.dll")]
                [return: MarshalAs(UnmanagedType.Bool)]
                public static extern bool PeekMessage(out NativeMessage lpMsg, IntPtr hWnd, uint wMsgFilterMin, uint wMsgFilterMax, uint wRemoveMsg);
    
                public enum WM : uint{
                    /// <summary>
                    /// Use WM_MOUSEFIRST to specify the first mouse message. Use the PeekMessage() Function.
                    /// </summary>
                    WM_MOUSEFIRST = 0x0200,
                    /// <summary>
                    /// Use WM_MOUSELAST to specify the last mouse message. Used with PeekMessage() Function.
                    /// </summary>
                    WM_MOUSELAST = 0x020E,
                }
                [StructLayout(LayoutKind.Sequential)]
                public struct NativeMessage
                {
                    public IntPtr handle;
                    public uint msg;
                    public IntPtr wParam;
                    public IntPtr lParam;
                    public uint time;
                    public System.Drawing.Point p;
                }
            }
        }
    

    Please test.

    ~josef

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two panels in update panel. In panel1, there is button. If I
In one page I have two form for search: <form class=search-panel method=post action= onsubmit=return
Let's say I have a created a Form class and a CustomControl class. On
i have two panel. when i'm click on the left panel items its calling
The situation is very simple, I have two panel. In the event of OnMouseOver
I have a two panel wxPython GUI set up. In my right panel, I
I currently have two panels within another large panel. The left panel is for
I have three info panels (divs with IDs of panel-one , panel-two and panel-three
I have 2 pictureboxes on a panel at two separate locations which will become
I have a viewport with two items : an authentication form and a tab

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.