Fade background behind a form

OmkarHcl 206 Reputation points
2023-07-16T07:40:39.1733333+00:00

Good Morning , I have a form named form1 in which there is a panel named panel1 . I am using this panel to open rest of the forms of my project . form 2 , Form3 , form 4 and form5 . in which form3 is actually a login form . Now , form2 contains a button called login And when the user clicks on it , form3 is opened . what I am trying is as soon as the form3 is opened in this panel1 (of form1 ) , i want that form2 which is behind that login form , should be visible partially . I have write the code for opening the login form over form2 , but trying to make the form2 visible partially . Can you pls suggest how to get the effect .

below is code for opening form3 when form2 is loaded

   public static void showwindow()
        {
            form3 f = new form();
            f.TopLevel = false;
            panel1.Controls.Add(f);
            f.FormBorderStyle = FormBorderStyle.None;
            f.StartPosition = FormStartPosition.CenterParent;
            f.Anchor = AnchorStyles.None;
            f.ControlBox = false;
            f.BringToFront();
            f.Show();
        }

below is the image of what i am trying to get

Shading form

Developer technologies | Windows Forms
Developer technologies | C#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
{count} votes

Answer accepted by question author
  1. Karen Payne MVP 35,596 Reputation points Volunteer Moderator
    2023-10-04T20:18:22.74+00:00
    1 person found this answer helpful.
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Anonymous
    2023-07-17T10:19:12.0666667+00:00

    Hi @OmkarHcl , Welcome to Microsoft Q&A.

    When you add a form to a panel, you add it as a control.

    So the Opacity and TransparencyKey of the form will be invalid.

    The easiest way is to reduce the useless part of the login form, reduce the space occupied by the controls, and modify the zoom form.

    According to your way of thinking, there should be an additional panel in selectcompany, login should be displayed in this panel, and then use select to switch. You won't have this problem anymore.

    7_17_3

    Best Regards,

    Jiale


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. OmkarHcl 206 Reputation points
    2023-10-05T13:37:43.5733333+00:00

    @Karen Payne MVP , Exactly what i was looking for . Accurate answer in the link you provided .


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.