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

| Author: | TX Text Control Support Department |
| Language: | C# .NET |
| Version: | 1.0 |
| Released: | March 29, 2006 |
| Last modified: | January 11, 2008 |
| Requirements: | TX Text Control .NET with C# .NET |
| Download code: | tabstop_guide_sample.zip |

Tabstop guides are a useful feature that allow end users to format text. This sample application shows you how to implement guides for tabstops and inline indent markers in TX Text Control.
By using the CreateGraphics method of TX Text Control, the guides are created and shown when the user clicks on the RulerBar.
The guides are not only used for positioning tabstops, but also for the indent markers, so users can easily place tabstops or indents at the correct position.
To show a tabstop guide, the MouseDown event of the RulerBar is used and a line is drawn on TX Text Control.
private void rulerBar1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == MouseButtons.Left) { textControl1.CreateGraphics().DrawLine(Pens.DarkGray,_ e.X, 0 , e.X, textControl1.Height); } }
After that, the MouseMove event will be used to capture the movement of the mouse and move the line accordingly.
private void rulerBar1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == MouseButtons.Left) { textControl1.Refresh(); textControl1.CreateGraphics().DrawLine(Pens.DarkGray,_ e.X, 0, e.X, textControl1.Height); } }
If the MouseUp event occurs, the tabstop or indent is automatically placed by the RulerBar at the current position and the TX Text Control's content needs to be refreshed.
private void textControl1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == MouseButtons.Left) { textControl1.Refresh(); } }
The minimum requirements for this sample application are TX Text Control .NET trial version and Visual Studio 2003.