| Skype: | TextControlSupport | |
| Orders: | 877-462-4772 |

| Author: | TX Text Control Support Department |
| Language: | Visual Basic .NET |
| Version: | 1.0 |
| Released: | December 01, 2004 |
| Last modified: | January 11, 2008 |
| Requirements: | TX Text Control .NET with Visual Basic .NET |
| Download code: | tx_sample_dotnet_thumbs.zip |
An interesting navigation feature to add to a word processor is that of thumbnail navigation -- create a thumbnail of every page in a document and display it on the left of the currently active document (as illustrated in the screenshot to the right).
In this sample application, you will learn how to create such navigation by using a small, zoomed TX Text Control. Every page of the current document is displayed on a separate TX Text Control that is added to a scrollable panel control.
First of all, we have to create a new TX Text Control for every page and copy the current page using the Load and Save methods into the small thumbnail TX Text Control. Consider the following code:
For pageCount = 1 To TextControl1.Pages Dim thumb As New TXTextControl.TextControl Dim dataBuffer() As Byte With thumb [...] TextControl1.Selection.Save(dataBuffer, TXTextControl.BinaryStreamType.InternalFormat) AddHandler .Click, AddressOf thumb_Click AddHandler .MouseHover, AddressOf thumb_Hover AddHandler .MouseLeave, AddressOf thumb_Leave End With Panel2.Controls.Add(thumb) If Not dataBuffer Is Nothing Then thumb.Load(dataBuffer, TXTextControl.BinaryStreamType.InternalFormat) End If Next
Additionally, we add some event handlers for the thumbnails: a Click, a MouseHover and a MouseLeave event. The current page is stored in the Tag property of the current control, so that this value can be used to navigate to the specified page and to display the page number, if the user moves the mouse over the thumbnail.
Private Sub thumb_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim myThumb As New TXTextControl.TextControl For Each myThumb In Panel2.Controls myThumb.BackColor = System.Drawing.Color.White Next myThumb = sender myThumb.BackColor = System.Drawing.Color.Beige TextControl1.Focus() TextControl1.InputPosition = New TXTextControl.InputPosition(myThumb.Tag, 1, 0) End Sub
The thumbs are updated, if a new page is inserted to the document. You can also force the update by pressing the 'Update...' button.
The minimum requirements for this sample application are TX Text Control .NET trial or TX Text Control .NET Enterprise retail version and Visual Studio .NET 2003.