Displaying multiple panels on the same form - Windows Application

Feb 16 2008 10:33 PM

Hi,

I am trying to build a windows application in C#. I have two panels namely encryptPanel and decryptPanel, both located on the same area on the main windows form. I want to make them visible/invisible based on the selection made by the user from a dropdownlist. Here is my code

string choice = list.SelectedIndex.ToString();
if (choice == "0")
{
encryptPanel.Visible = true;
encryptPanel.BringToFront();
decryptPanel.Visible = false;
}
else
{
 if (choice == "1")
 {
 encryptPanel.Visible = false;
 decryptPanel.Visible = true;
 decryptPanel.BringToFront();
 }
}

Now, the problem I am facing is, when the the user selects 0, encryptPanel becomes visible and decryptPanel becomes invisible. And when user selects 1, encryptPanel gets invisible but decryptPanel doesnot become visible? Can anyone tell me what I am missing?

Thanks in advance.

Jai


Answers (2)