logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

New Topic Post Reply
Options
Go to last post Go to first unread
Miralon  
#1 Posted : Wednesday, October 4, 2017 1:07:28 AM(UTC)
Quote
Miralon

Rank: Newbie

Groups: Registered
Joined: 6/26/2017(UTC)
Posts: 8
Poland

Is it possible to scroll document shown id pdfViewer control using arrow keys (up, down)? It can be done using mouse wheel, but how to achieve this using keyboard arrows keys?

Michal
Paul Rayman  
#2 Posted : Wednesday, October 4, 2017 3:25:51 AM(UTC)
Quote
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 1,138

Thanks: 10 times
Was thanked: 133 time(s) in 130 post(s)
Winfroms or WPF?
Miralon  
#3 Posted : Wednesday, October 4, 2017 4:25:09 AM(UTC)
Quote
Miralon

Rank: Newbie

Groups: Registered
Joined: 6/26/2017(UTC)
Posts: 8
Poland

WinForms.

Michal
Paul Rayman  
#4 Posted : Wednesday, October 4, 2017 4:50:57 AM(UTC)
Quote
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 1,138

Thanks: 10 times
Was thanked: 133 time(s) in 130 post(s)
Code:

...
pdfViewer1.KeyDown += PdfViewer1_KeyDown;
...

private void PdfViewer1_KeyDown(object sender, KeyEventArgs e)
{
	int pageStep = pdfViewer1.AutoScrollMinSize.Height / pdfViewer1.Document.Pages.Count;
	int lineStep = pageStep / 30;
	var asp = pdfViewer1.AutoScrollPosition;

	switch (e.KeyCode)
	{
		case Keys.Down:
			pdfViewer1.AutoScrollPosition = new Point(asp.X, -asp.Y + lineStep);
			break;
		case Keys.Up:
			pdfViewer1.AutoScrollPosition = new Point(asp.X, -asp.Y - lineStep);
			break;
		case Keys.PageDown:
			pdfViewer1.AutoScrollPosition = new Point(asp.X, -asp.Y + pageStep);
			break;
		case Keys.PageUp:
			pdfViewer1.AutoScrollPosition = new Point(asp.X, -asp.Y - pageStep);
			break;
	}
}

Miralon  
#5 Posted : Wednesday, October 4, 2017 5:06:04 AM(UTC)
Quote
Miralon

Rank: Newbie

Groups: Registered
Joined: 6/26/2017(UTC)
Posts: 8
Poland

Great! Thanks.

Michal
Quick Reply Show Quick Reply
Users browsing this topic
Guest (2)
New Topic Post Reply
Forum Jump  
You can post new topics in this forum.
You can reply to topics in this forum.
You can delete your posts in this forum.
You can edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.