| |

VerySource

 Forgot password?
 Register
Search
View: 1559|Reply: 12

datagrieview scroll bar control

[Copy link]

1

Threads

8

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-3-14 00:00:01
| Show all posts |Read mode
datagrieview scroll bar control automatically
Scroll to selectrow
Or scroll down with a mouse click?
Reply

Use magic Report

0

Threads

15

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-6-15 20:15:01
| Show all posts
Understand, it's the same effect as the scroll bar property when it is similar to the multiline of textbox...
  
  It seems I can only help you

I haven't tried it in gridview. I don't know if my explanation is correct..
Reply

Use magic Report

0

Threads

8

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-6-21 22:45:02
| Show all posts
The solution is as follows:

private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
   int numScroll = 5; //This value needs to be adjusted according to the height of dataGridView1
   if (e.RowIndex <numScroll)
       return;
   dataGridView1.FirstDisplayedScrollingRowIndex = e.RowIndex-numScroll;
   dataGridView1.Refresh();
}

The specific effect requires you to debug yourself. . . . .
Reply

Use magic Report

1

Threads

8

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

 Author| Post time: 2020-7-23 21:30:02
| Show all posts
That is to say, when a certain index row is queried with select, the scroll bar automatically scrolls.. Let the row be displayed at the top/bottom/most!
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-25 09:45:01
| Show all posts
datagrieview
Reply

Use magic Report

1

Threads

8

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

 Author| Post time: 2020-7-25 10:15:01
| Show all posts
Yes... is there a way?
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 Invalid IP Address

Post time: 2020-7-27 15:15:02
| Show all posts
The variable numScroll forhyuk0321can be as follows;
int numScroll = dataGridView1.DisplayedRowCount(false);

What I don't understand is the following statement;
dataGridView1.FirstDisplayedScrollingRowIndex = e.RowIndex-numScroll;
Why e.RowIndex-numScroll, isn't it enough to use e.RowIndex directly?
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 Invalid IP Address

Post time: 2020-7-27 15:45:01
| Show all posts
In fact, I think the automatic scrolling of the DataGridView is required, and the selected items jump around. It feels very bad. It is better not to automatically scroll!!
Reply

Use magic Report

0

Threads

13

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-7-28 06:15:02
| Show all posts
There are two ideas:
1. After selecting the cell, change the top value of the selected row to the value of the top/middle/bottom row of the datagridview
2. Hide all the rows above the selected row, and the selected row will automatically jump to the top
Reply

Use magic Report

0

Threads

8

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-7-28 07:30:01
| Show all posts
Tot0112405:
   In fact, the intention of lz is like dynamically positioning (finding) specific graphic blocks in a graphical interface to the center of the view. You can write a simple program, (dynamically add data: timer, statically add data from the database) OK), after the experimental results, you can understand why I wrote that way.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list