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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:18:02+00:00 2026-05-22T20:18:02+00:00

When I remove item from ListBox , it’s scrolling to selected item. If there’s

  • 0

When I remove item from ListBox, it’s scrolling to selected item. If there’s no item selected, then it’s scrolling to top of the list. Is it possible to make it stay still when removing items?

I don’t really need selecting items enabled, but even if I set selecting mode to none, it’s scrolling to the top.

I’m using listBox1.Items.Remove(...) method for removing items.

I tried to get AutoScrollOffset before removing and then after removing set it the same value of X and Y as it was before, but it doesn’t work.

I put Thread.Sleep and MessageBox right after method that removes item and it looks like it scrolls before my message is displayed, so it must be Items.Remove causing the scroll.

My ListBox code looks like that:

private ListBox listBox1 = new ListBox();
this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                            | System.Windows.Forms.AnchorStyles.Left)
                            | System.Windows.Forms.AnchorStyles.Right)));
this.listBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.listBox1.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
this.listBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.listBox1.FormattingEnabled = true;
this.listBox1.IntegralHeight = false;
this.listBox1.ItemHeight = 16;
this.listBox1.Location = new System.Drawing.Point(14, 6);
this.listBox1.Name = "listBox1";
this.listBox1.ScrollAlwaysVisible = true;
this.listBox1.SelectionMode = System.Windows.Forms.SelectionMode.None;
this.listBox1.Size = new System.Drawing.Size(180, 388);
this.listBox1.TabIndex = 0;
this.listBox1.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.listBox1_DrawItem);

in listBox1_DrawItem() is just DrawBackground(), Graphics.DrawString(), DrawFocusRectangle(), and nothing else that could matter.

Maybe there is some property I don’t know about or maybe I need to install update or something…

  • 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-22T20:18:02+00:00Added an answer on May 22, 2026 at 8:18 pm

    Try this:

    int tempTopIndex = listBox1.TopIndex;
    listBox1.Items.Remove(yourItem);
    listBox1.TopIndex = tempTopIndex;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to remove item from listbox based on it's name but
Is there a way to remove an item from a listbox based on a
Or more generally, how do I remove an item from a colon-separated list in
How to remove selected items from ListBox when a datasource is assigned to it
I am trying to remove an item from listbox but is not working. even
i'm trying to remove an item from a one to many list and have
I need to add and remove items from a list of integers. There will
In my base page I need to remove an item from the query string
If I remove all the ' characters from a SQL query, is there some
hey, i m trying sice few days to remove an item from a databinded

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.