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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:35:18+00:00 2026-05-26T07:35:18+00:00

I have a datagrid view like this….in below image well thats works fine… I

  • 0

I have a datagrid view like this….in below image well thats works fine…

I need to hook up an event in vertical side bar ..

i mean if i click on upper arrow in the scroll bar i want to do something …

To be more specific i want to get the id of first upper record id when i click on upper arrow in vertical scroll bar..

 using System.Reflection;
 using System.Windows.Forms;

bool addScrollListener(DataGridView dgv)
{
   bool ret = false;

   Type t = dgv.GetType();
    PropertyInfo pi = t.GetProperty("VerticalScrollBar", BindingFlags.Instance | BindingFlags.NonPublic);
    ScrollBar s = null;

   if (pi != null)
    s = pi.GetValue(dgv, null) as ScrollBar;

   if (s != null)
  {
    s.Scroll += new ScrollEventHandler(s_Scroll);
    ret = true;
  }
  return ret;
}

private void s_Scroll(object sender, ScrollEventArgs e)
{
    if (e.ScrollOrientation == ScrollOrientation.VerticalScroll)
    {
        if (e.Type == ScrollEventType.ThumbPosition)
        {
            if (e.Type == ScrollEventType.SmallIncrement)
            {

                int i = dgvMembers.FirstDisplayedScrollingRowIndex;
                int idemebers =Convert.ToInt32(dgvMembers.Rows[i].Cells["Id"].Value.ToString());
                getMemberInfo(i, idemebers); // i want to the details of selected record into text boxes 

            }
            if (e.Type == ScrollEventType.SmallDecrement)
            {

                int i = dgvMembers.FirstDisplayedScrollingRowIndex;
                int idemebers = Convert.ToInt32(dgvMembers.Rows[i].Cells["Id"].Value.ToString());
                getMemberInfo(i, idemebers);

            }
        }

    }   
} 

but this event does not fire

s.Scroll += new ScrollEventHandler(s_Scroll);

it does not goes into the this event …

would any one pls help on this…

Many thanks in advance

  • 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-26T07:35:19+00:00Added an answer on May 26, 2026 at 7:35 am

    Try using the DataGridView.Scroll event.

    To be more specific i want to get the id of first upper record id when i click on upper arrow in vertical scroll bar

    In your DataGridView.Scroll event handler, you can do this (the upper arrow is considered a small decrement:

    if (e.ScrollOrientation == ScrollOrientation.VerticalScroll
        && e.Type == ScrollEventType.SmallDecrement)
    {
        int i = dgvMembers.FirstDisplayedScrollingRowIndex;
        // your code to process the first displayed row here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having problem with datagrid view. I have attached an image with the code
I have a data grid that looks like this <tk:DataGrid ItemsSource={Binding Parents} AutoGenerateColumns=False> <tk:DataGrid.Columns>
I have this datagrid view: Now when the first row is double clicked i
I have a datagrid which gets data like this: public struct MyData { public
Is it possible to have something like Data Grid or Grid View control in
I have a datagrid view which is editable. I'm getting the value of a
I'm using .Net 4.0 and have a DataGrid in a view. I have implemeneted
I have a ListBox or DataGrid filled with thousands of entries. I would like
I have a datagrid with different types of columns, like I have checkboxes, combo
I have a WPF view (I use MVVM pattern) with a datagrid and some

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.