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

| Author: | TX Text Control Support Department |
| Language: | C# .NET |
| Version: | 1.0 |
| Released: | August 08, 2007 |
| Last modified: | January 11, 2008 |
| Requirements: | TX Text Control .NET with Visual Studio 2005 |
| Download code: | tx_restart_lists.zip |
TX Text Control provides fully featured dialog boxes to set almost all formatting options. Using the ListFormatDialog, it is possible to adjust all formatting attributes of bullets and numbered lists. Additionally, it allows the user to restart a numbered list, so that the current item starts with the default value.
Sometimes, it is necessary to provide a button in the button bar that allows the user to restart a list. This saves the user from having to open the respective dialog box. As always in TX Text Control, all settings of the dialog boxes are accessible from within the API of TX Text Control.
To restart a list, the ListFormat.RestartNumbering property has been implemented. If this property is set to true, the current item will be restarted with the default value.
textControl1.Selection.ListFormat.RestartNumbering = true;
If the user inserts another item by pressing return, the following item inherits the RestartNumbering value. In other words, the new item is restarted as well. This can be avoided by setting the RestartNumbering property to false.
This samples uses a global flag that indicates whether the new list item should be continued or not.
private bool restartFlag = false; private void button1_Click(object sender, EventArgs e) { textControl1.Selection.ListFormat.RestartNumbering = true; restartFlag = true; }
The KeyUp event is used to trap the return key and to continue the newly inserted list item.
private void textControl1_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode != Keys.Return || restartFlag == false) return; if (textControl1.Selection.ListFormat.Type == TXTextControl.ListType.Numbered) { textControl1.Selection.ListFormat.RestartNumbering = false; restartFlag = false; } }
To use the downloadable version of this sample you need TX Text Control .NET 13.0 trial version or better.