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 8817561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:52:43+00:00 2026-06-14T04:52:43+00:00

I have a user control in my project and I want when I click

  • 0

I have a user control in my project and I want when I click on a button to add this user control to a form, but if the user control is already in the form I want to show it.

This the code I wrote so far:

Using GstAbonnement As New GestionAbonnement
            GstAbonnement.Dock = DockStyle.Fill
            Me.Controls.Add(GstAbonnement)
End Using

How can I test if the user control is already in the form or not ?

  • 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-14T04:52:44+00:00Added an answer on June 14, 2026 at 4:52 am

    With your current code, that control will never be found in the form because the Using...End Using syntax with dispose of the control.

    Try changing it to this:

    Dim GstAbonnement As New GestionAbonnement
    GstAbonnement.Name = "gestionAbonnement1"
    GstAbonnement.Dock = DockStyle.Fill
    Me.Controls.Add(GstAbonnement)
    

    Notice I supplied a name for the control.

    Now you can simply check the key if the control was in the collection or not:

    If Me.Controls.ContainsKey("gestionAbonnement1") Then
      Me.Controls("gestionAbonnement1").Visible = True
      Me.Controls("gestionAbonnement1").BringToFront()
      MessageBox.Show("Found!")
    End If
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have user control, which i render on several views. i want to show
I have a user control that has button whose click event handler contains the
I have a user-control and I want to use it in some other project.
I have this User Control XAML: <Window x:Class=MyProj.Dialog xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006 xmlns:d=http://schemas.microsoft.com/expression/blend/2008 xmlns:shell=http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell mc:Ignorable=d>
I have a user control with a div like this: <div runat=server id=pnlShippingMethods class=checkoutstep>
I have created a C# user control which I want to use in VB.NET
I have ElementFlowContainer user control that contains ElementFlow from FluidKit.Showcase project. <UserControl x:Class=Controls.ElementFlowContainer> <Grid>
I have a user control that generates a series of arrow buttons. I want
I've made a simple project to illustrate my problem. I have a user control
I have added two user control to the project. One is for portrait and

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.