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

  • Home
  • SEARCH
  • 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 8417869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:09:44+00:00 2026-06-10T02:09:44+00:00

I am trying to make a control that can hold a variable amount of

  • 0

I am trying to make a control that can hold a variable amount of strings and adjust it’s height dynamically by programmatically changing the height of this control.

So far I have tried the Checked Listbox and the ListView.

The listbox keeps showing a horizontal scrollbar, even though it has been set to false.
The ListView looks more promising but it refuses to realign the items in the box:

public partial class Form1 : Form
{
    string[] content = 
        {
            "Lorem",
            "ipsum",
            "dolor",
            "sit",
            "amet",
            "consectetur",
            "adipiscing",
            "elit" ,
            "Integer" ,
            "commodo" ,
        };

    ListView listView1 = new ListView();

    public Form1()
    {
        InitializeComponent();

        listView1.Size = new System.Drawing.Size(300, 22);
        listView1.Font = new Font(FontFamily.GenericMonospace, 10);
        listView1.CheckBoxes = true;
        listView1.View = View.List;
        listView1.Scrollable = false;

        this.Controls.Add(listView1);

        groupBox1.Controls.Add(listView1);

        foreach (string str in content)
        {
            listView1.Items.Add(str.PadRight(12));
        }
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        listView1.Height = 100;
    }
}

If I move the listView1.Height = 100; to the constructor of the class it will work so obviously that’s where the problem lies. I can’t seem to find what the root cause of this problem is though… Should I call some member function of the listbox to re-place it’s items?

Update
After fiddling some more it seems that the behavior can be reproduced also by adding items to the list using the designer, setting all the anchors, snap to the edges of the form and resizing the form at runtime. Then, again, the items will not realign. Still stuck on how to force to re-position the items in the listview though.

  • 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-10T02:09:45+00:00Added an answer on June 10, 2026 at 2:09 am

    Only now I realize What my answer is really doing. I basically reimplemented the Checkbox using an additional label for the text. Right…

    Solution
    My solution ultimately boils down to a couple of checkboxes in a flowlayout panel.

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

Sidebar

Related Questions

Trying to make a make generic select control that I can dynamically add elements
I trying to make a Control that inherits from System.Windows.Form.Label that can resize to
I am trying to make a control that makes use of the MapPoint 3d
I'm trying to make an Address control that has an IsReadOnly property, which will
Trying to make a simple number clicker control for BlackBerry 6/7, like this: At
I am trying to make a CPTableColumn that can change values without having to
I'm trying to make an app on an Android device that will control an
I'm trying to make a generic Search UserControl that can be given some values,
I'm trying to make sense of the RadWindow/RadWindowManager relation. I see that there can
I'm trying to create a custom control that can be shared by both Silverlight

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.