Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I don't want to use DataGridview auto ScrollBars. I want to use VScrollBar and HScrollBar from Visual Studio 2010.
But I don't know how to implement VScrollBar and HScrollBar with DataGridView Control Using C# window form.
Plaese, give me instruction and solution.
Thanks !
Posted
Updated 3-Dec-14 20:51pm
Comments
Praveen Kumar Upadhyay 4-Dec-14 5:11am    
Why you are posting the same question multiple times.

http://www.codeproject.com/Questions/849649/How-to-Use-VScrollBar-and-HScrollBar-with-DataGrid?arn=15

1 solution

Set ScrollBars property of your Datagridview to False.
C#
ScrollBars =None

Add hScrollBar and vScrollBar to your form.

In your hScrollBar Scroll Event
C#
private void hScrollBar1_Scroll(object sender, ScrollEventArgs e)
      {
          dataGridView1.HorizontalScrollingOffset = hScrollBar1.Value;
      }


In your vScrollBar Scroll Event
C#
private void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
      {
        //  int verticalval = dataGridView1.VerticalScrollingOffset;
          dataGridView1.FirstDisplayedScrollingRowIndex = vScrollBar1.Value;


      }
 
Share this answer
 
Comments
Cho Lay 4-Dec-14 3:38am    
Thanks
your answer is ok.
syed shanu 4-Dec-14 3:39am    
Good - mark it as Answerd.
Cho Lay 9-Dec-14 5:23am    
hScrollBar_scroll() is ok but vScrollBar_Scroll() have some problem
if i drag vScrollBar rise error as follow:
"Specified argument was out of the range of valid values.
Parameter name: value"
i don't know how to solve.Please help me and Give me instruction.Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900