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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:53:35+00:00 2026-05-15T19:53:35+00:00

I’ve got a strange problem here. I have a winforms panel which programatically has

  • 0

I’ve got a strange problem here. I have a winforms panel which programatically has labels and a usercontrol (which is capable of collapsing/expanding) added. The user defined controls are in groups which is where the labels come in to it. Due to the size and number of controls I have set the panel to support scrolling.

So far so good: The problem occurs when the panel is scrolled down away from the top. Any manipulation of controls within the panel results in dead space (empty) at the top.

Manipulation takes place as follows:

When a control is added, removed or resized the “RearrangeControls()” method is called. The method maintains an integer for which the height of all controls (and empty space to prevent controls appearing right next to each other) which is added to every time a control is adjusted.

Iteration takes place through groups and then through instances of this user control to ensure that they are grouped properly. (I hope this explination makes sense)

My Rearrange method is included below:

  private void RearrangeControls()
  {
     Console.WriteLine(String.Format("Top of panel: {0}", pnlMain.Top));
     this.SuspendLayout();
     //sort ranges in to ascending order, this is the primary grouping
     _lRanges.Sort(CompareStringAscending);

     //now sort items by alphabetical order, we will filter out groups later so this will not be a problem
     _lItems.Sort(CompareSelectionDetailViewAscending);

     int iYPos = 0;

     //first sort through by 
     foreach (string selectedRange in _lRanges)
     {
        int iRangeControlCount = 0;

        KryptonLabel label = pnlMain.Controls[selectedRange] as KryptonLabel;
        label.Location = new Point(_iTitleIndent, iYPos);

        iYPos += label.Height + _iControlSpacing;

        //now sort views
        foreach (SelectionDetailView selectionDetailView in _lItems)
        {
           if (selectionDetailView.Range == selectedRange)
           {
              selectionDetailView.Location = new Point(_iDetailIndent, iYPos);
              //Console.WriteLine(String.Format("{0} {1} {2}", selectionDetailView.Name, selectionDetailView.Location.X.ToString(), selectionDetailView.Location.Y.ToString()));
              iYPos += selectionDetailView.Height + _iControlSpacing;

              iRangeControlCount++;
           }
        }

        //if this is zero, then it meant the last label we aded has no controls associated wiht it.  If this is the case we shoudl remove it from the panel
        if (iRangeControlCount == 0)
        {
           iYPos -= label.Height + _iControlSpacing;
           pnlMain.Controls.Remove(label);
        }

        Console.WriteLine(String.Format("Y: {0}", iYPos));
     }

     pnlMain.ScrollControlIntoView(_oSelectedItem);
     this.ResumeLayout();
  }

The Y values of all controls within this panel all start at 0 so they should be at the top. I’ve searched around and haven’t been able to find any information about what this error is. does anyone know what’s going on with this thing? I’d greatly appreciate any pointers/help/advice on this matter.

  • 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-15T19:53:36+00:00Added an answer on May 15, 2026 at 7:53 pm

    Problem solved.

    I needed to use use the following:

    int iYpos = pnlMain.AutoScrollPosition.Y
    

    If anyone else runs in to the same probme I hope this helps.

    (At which point I finally collape in front of keyboard – it’s been a long day)

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

Sidebar

Ask A Question

Stats

  • Questions 466k
  • Answers 466k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The second method passes a reference to hash, while the… May 16, 2026 at 1:39 am
  • Editorial Team
    Editorial Team added an answer This should work: $("#country_id").result(function() { $("#state_id").flushCache(); }); It will clear… May 16, 2026 at 1:39 am
  • Editorial Team
    Editorial Team added an answer I've found the solution, the keyword has to be defined… May 16, 2026 at 1:39 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.