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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:27:50+00:00 2026-06-09T19:27:50+00:00

I have made a control library and two user controls. userControl_1 contains a Panel

  • 0

I have made a control library and two user controls.

userControl_1 contains a Panel and an ImageList that I have "loaded" with
images in design time.

userControl_2 contains a PictureBox

I have placed userControl_1 on a windows form. The userControl_2 is placed on the panel area in userControl_1.

The goal is to choose a image from the imageList and display it with the pictureBox, something like this:

nameOfPictureBox.Image = nameOfList.Image[number]

But I don’t get it to work. I don’t understand how to communicate between the user controls? I guess the piece of code above should be inside the userControl_1? But where do I put the code, inside the userControl_1.cs class file or the userControl_1.Designer.cs file?

Preciate some help! Thanks!

  • 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-09T19:27:51+00:00Added an answer on June 9, 2026 at 7:27 pm

    The designer file is generally only used for web control definitions, and is generated, so should not be the place for your code.

    You will want to extend any functionality into the code behind file (.cs) of the user control.

    One easy way to expose data from a user control is to create public properties in the code behind of the user control to encapsulate the knowledge of the control but still expose data.

    Something like this on the UserControl_2 class:

    public Image PictureBoxImage{
        get { return pictureBox.Image; }
        set { pictureBox.Image = value; }
    }
    

    You then have an easy property to work with that can hide the inner structure of the control, but still allow your UserControl_1 code behind to set it.

    KDiTraglia’s code can then be tweaked to do something like:

    foreach(var item in this.Panel)
    {
        if (item is UserControl_2)
        {
             var ctrl = (UserControl_2)item;
             ctrl.PictureBoxImage = ...
        }
    }
    

    This then allows the user control to delegate down to the appropriate inner controls, without UserControl_1 needing to know about that structure.

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

Sidebar

Related Questions

I'm having an issue where I have made a user control with two content
I have made a web user control (.ascx) which consists of the two html
I have made a user control that allows an image to be uploaded and
I have made a basic ascx control which is just a panel with a
We have Tabs-Menu controls which rely on jQuery library and the dev-manager insist that
I have a custom control library with a resouce dictionary that references an image
I have made a control that creates an electronic invite to an event. The
I have made a control in silverlight that has a SolidColorBrush property. In XAML,
I have written an ActiveX control in C# and have made it working using
I have made a jQuery toggle for a menu that I had in mind.

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.