Skype:TextControlSupport
Orders:877-462-4772
TX Text Control - word processing components.
What is this?Syndicate this content

How to build a context formatting bar

This source code snippet requires TX Text Control .NET
Author:TX Text Control Support Department
Language:C#
Version:1.0
Released:May 30, 2006
Last modified:January 11, 2008
Requirements:TX Text Control .NET with Visual Studio .NET 2003
Download code:tx_context_buttonbar.zip Download [13.56 KB, ZIP]
Click to enlarge

The latest beta implementation of Microsoft Word introduces a new formatting bar that is displayed where it is required. If a part of the text is selected, a small button bar with the most important formatting features, such as bold or italic, is displayed.

This sample shows how to implement such a context formatting bar, complete with fading effects. The formatting bar fades in when the mouse moves over the selected text.

Implementing such functionality is easy with TX Text Control: We simply use the TX Text Control button bar, remove some buttons and display it on a transparent form. The opacity value is dependent upon the distance between the mouse cursor and the selection.

We do not need to worry about the formatting itself, as this is completely encapsulated in the ButtonBar class. The only complicated part of this algorithm is the positioning of the button bar at the current selection. We use the InputPosition class to get the current input location. Additionally, the current scroll location and the position of the parent form must be included in the calculation.

The minimum requirements for this sample application are TX Text Control .NET trial version and Visual Studio .NET 2003.

top

Top 10 Bestselling Product Award 2007Top 25 Publisher Product Award 2007Top 10 Bestselling Product Award 2007 in JapanTop 25 Bestselling Product Award 2006Top 25 Bestselling Publisher Award 2006Reader's Choice Award, dot.net magazin, 3rd place