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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:46:44+00:00 2026-05-28T04:46:44+00:00

I wrote a function to dynamically add elements to the Panel. public int State;

  • 0

I wrote a function to dynamically add elements to the “Panel”.

public int State;        
public Point Point = new Point(0, 0);
public void DialogAdd(string message, string author)
        {
            var d = new DialogMessage();
            if(State == 0)
            {
                d.BackColor = Color.FromArgb(255, 237, 241, 245);
                State = 1;
            }
            else
            {
                State = 0;
            }


            d.Controls["name"].Text = author;
            d.Location = new Point(0, Point.Y);
            d.Controls["msg"].Text = message;
            Point.Y += d.Size.Height;
            Controls["panel1"].Controls.Add(d);

        }

DialogMessage is UserControl, that haves property “AutoSize=true” on all components.
This panel has got the AutoScroll property, so has got scrollbars.
The problem is that the elements are added in different ways, depending on the position of the scrollbar. If the scrollbar is at the top, then all added as needed.

enter image description here

but if at the time of adding the scrollbar at the bottom, then add items going wrong

enter image description here

please tell me what I’m doing wrong and how to fix it? Thank you. sorry for bad english

  • 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-28T04:46:45+00:00Added an answer on May 28, 2026 at 4:46 am

    When placing the controls inside the panel, you have to compensate for the scroll position:

    Basically, try using this line:

    d.Location = new Point(0, panel1.AutoScrollPosition.Y + Point.Y);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have wrote a little function to dynamically include CSS file or JS file.
I'm using jQuery to dynamically add form elements to a web form. Users can
Awhile back, I found the following javascript function that allows you to dynamically add
I wrote a JS script to dynamically add rows on a table. On a
I wrote a jQuery function that dynamically adds or removes messages boxes from the
I wrote this function that's supposed to do StringPadRight("Hello", 10, "0") -> "Hello00000" .
I wrote this function for filling closed loop, pixvali is declared globally to store
I wrote a function in bash script. However, it's complaining about syntax. I really
I wrote this function to get the unread count of google reader items. function
I wrote this function to get a pseudo random float between 0 .. 1

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.