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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T21:33:27+00:00 2026-05-28T21:33:27+00:00

hello creating a custom object may be a widely published topic, but my lack

  • 0

hello creating a custom object may be a widely published topic, but my lack of coding skills proves problematic in actually implementing what i’m trying to do.

in a nutshell i’m adding controls at runtime in a flowpanelLayout. right now it’s just listboxes, that code is all working fine. i would like a way to label the listboxes that are getting added, i can’t think of a better way to do this than to use a text label. i was thinking it would be slick to create some sort of custom control (if possible) which is a listbox and a textlabel like one above the other or something. this way i can add the new custom control in my current code and assign the listbox attributes and label text, etc all in one motion.

this is what i was thinking, maybe there’s even a better way to do this.

my current listview creation code:

public void addListView()
        {

            ListView newListView = new ListView();
            newListView.AllowDrop = true;
            newListView.DragDrop += listView_DragDrop;
            newListView.DragEnter += listView_DragEnter;
            newListView.MouseDoubleClick += listView_MouseDoubleClick;
            newListView.MouseDown += listView_MouseDown;
            newListView.DragOver += listView_DragOver;
            newListView.Width = 200;
            newListView.Height = 200;
            newListView.View = View.Tile;
            newListView.MultiSelect = false;

            flowPanel.Controls.Add(newListView);
            numWO++;

            numberofWOLabel.Text = numWO.ToString();
        }

maybe the actual best answer is simply to also add a textlabel here and define some set coordinates to put it. let me know what you think.

if a custom control is the way to go, please provide some resource or example for me – i’d appreciate it.

  • 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-05-28T21:33:28+00:00Added an answer on May 28, 2026 at 9:33 pm

    Here is a custom user control that can do that:
    You just need to set TitleLabelText to set the title.

    [Category("Custom User Controls")]
    public class ListBoxWithTitle : ListBox
    {
        private Label titleLabel;
        public ListBoxWithTitle()
        {
            this.SizeChanged +=new EventHandler(SizeSet);
            this.LocationChanged +=new EventHandler(LocationSet);
            this.ParentChanged += new EventHandler(ParentSet);
    
        }
        public string TitleLabelText
        {
            get;
            set;
        }
        //Ensures the Size, Location and Parent have been set before adding text
        bool isSizeSet = false;
        bool isLocationSet = false;
        bool isParentSet = false;
        private void SizeSet(object sender, EventArgs e)
        {
            isSizeSet = true;
            if (isSizeSet && isLocationSet && isParentSet)
            {
                PositionLabel();
            }
        }
        private void LocationSet(object sender, EventArgs e)
        {
            isLocationSet = true;
            if (isSizeSet && isLocationSet && isParentSet)
            {
                PositionLabel();
            }
        }
        private void ParentSet(object sender, EventArgs e)
        {
            isParentSet = true;
            if (isSizeSet && isLocationSet && isParentSet)
            {
                PositionLabel();
            }
        }
        private void PositionLabel()
        {
            //Initializes text label
            titleLabel = new Label();
            //Positions the text 10 pixels below the Listbox.
            titleLabel.Location = new Point(this.Location.X, this.Location.Y + this.Size.Height + 10);
            titleLabel.AutoSize = true;
            titleLabel.Text = TitleLabelText;
            this.Parent.Controls.Add(titleLabel);
        }
    
    }
    

    Example use:

        public Form1()
        {
            InitializeComponent();
    
            ListBoxWithTitle newitem = new ListBoxWithTitle();
            newitem.Size = new Size(200, 200);
            newitem.Location = new Point(20, 20);
            newitem.TitleLabelText = "Test";
            this.Controls.Add(newitem);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello can anybody solve this please I'm creating the object in the action class
I feel like I've missed something obvious, but when creating a custom control in
Hello I'm creating application for android no mater what kind but I need to
Hello I'm looping over a JSON object and creating a new map marker for
Hello I am trying to create an animation like creating heart like bubbles but
Hello dear programmers, I have a requirement for creating a custom tableviewcell with a
Hello I have a problem with generics, i'am creating a custom vertex structure for
Hello I am creating a Windows application (WPF) that is going to be running
Hello I am creating a CMS and some of the functionality of it that
Hello and thanks for your opinion. I am creating a webservice. This webservice will

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.