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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:07:24+00:00 2026-05-24T14:07:24+00:00

hopefully this is an easy one! I’m deriving from UserControl , and I am

  • 0

hopefully this is an easy one!

I’m deriving from UserControl, and I am overriding OnPaint. I want this control to be scrollable, but all I want is to be able to get the value of the scroll bars and handle where to draw everything myself. I have set up the following:

// How the hell do I get this scrolling to not return to zero?
this.Scroll += new ScrollEventHandler(TimelineControl_Scroll);

this.HorizontalScroll.Enabled = true;
this.HorizontalScroll.Visible = true;
this.HorizontalScroll.Minimum = 0;

this.VerticalScroll.Enabled = false;
this.VerticalScroll.Visible = true;

this.AutoScroll = false;

I am seeing the new value of the scroll position. However, the scroll bars always return to zero. What am I doing wrong?

  • 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-24T14:07:24+00:00Added an answer on May 24, 2026 at 2:07 pm

    I cannot reverse-engineer what that code is trying to do. AutoScroll is your friend. Here’s an example:

    public partial class UserControl1 : UserControl {
        public UserControl1() {
            InitializeComponent();
            this.SetStyle(ControlStyles.ResizeRedraw, true);
            this.AutoScroll = true;
            this.AutoScrollMinSize = new Size(1000, 0);
        }
        protected override void OnScroll(ScrollEventArgs se) {
            base.OnScroll(se);
            this.Invalidate();
        }
        protected override void OnPaint(PaintEventArgs e) {
            e.Graphics.TranslateTransform(this.AutoScrollPosition.X, this.AutoScrollPosition.Y);
            e.Graphics.DrawLine(Pens.Black, 0, 0, 1000, this.ClientSize.Height);
            base.OnPaint(e);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hopefully this is an easy one. I have a query that I want to
Hopefully this is easy to explain, but I have a lookup transformation in one
This will hopefully be an easy one, but I'm lacking the skills! <select name=search_category
This is hopefully very easy to do, but I can't find any doco on
This is hopefully an easy question to answer for someone familiar with Mozilla, but
Hopefully this is an easy one. In my app, I have an event page
Hopefully this is a quick one, and Easy if you know how... I'm writing
hopefully there's an easy solution to this one. I have my MVC2 project which
Hopefully this will be an easy one to answer. I created a class in
Hopefully this will be an easy one to answer. I am working on a

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.