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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:27:05+00:00 2026-05-11T22:27:05+00:00

How can I allow selected rows in a DataGridView (DGV) to be moved up

  • 0

How can I allow selected rows in a DataGridView (DGV) to be moved up or down. I have done this before with a ListView. Unfortunetly, for me, replacing the DGV is not an option (curses). By the way, the DGV datasource is a Generic Collection.

The DGV has two buttons on the side, yes, UP & Down. Can anyone help point me in the right direction. I do have the code that I used for the ListView if it’ll help (it did not help me).

  • 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-11T22:27:05+00:00Added an answer on May 11, 2026 at 10:27 pm

    If you programatically change the ordering of the items in your collection, the DGV should reflect that automatically.

    Sloppy, half-working example:

    List<MyObj> foo = DGV.DataSource;
    int idx = DGV.SelectedRows[0].Index;
    int value = foo[idx];
    foo.Remove(value);
    foo.InsertAt(idx+1, value)
    

    Some of that logic may be wrong, and this may not be the most efficient approach either. Also, it doesn’t take into account multiple row selections.

    Hmm, one last thing, if you’re using a standard List or Collection this isn’t going to go as smoothly. List and Collection on’t emit events that the DGV finds useful for databinding. You could ‘burp’ the databinding every time you change the collection, but a better solution would be for you to use a System.ComponentModel.BindingList. When you change the ordering of the BindingList the DGV should reflect the change automatically.

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

Sidebar

Related Questions

I have this code, how can I allow it to accept all typical image
I have a table containing cells with phone numbers. How can I allow the
I am trying to have a button for selected rows of my table. Here
Why I'm getting this error when deleting a row in DataGridView control? How can
I have a PHP script that inserts rows into a table based on selected
I have a DataGridView that is bound to a DataSet and I allow someone
How can I annotate my model so I can allow only alphabets like A-Z
Is there a standard MBEAN of JMX that can allow me to read files
As far as I know, Drupal Services Module can allow PHP scripts to communicate
When creating a child process in C++ using Windows API, one can allow inheritance

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.