home *** CD-ROM | disk | FTP | other *** search
- /*+==========================================================================
- File: DataEdit.cs
-
- Summary: Extends the default functionality of the WFC Edit control
- by providing two extra methods.
-
- Classes: DataEdit
-
- Functions: Append, TruncateOneCharFromEnd
-
- ----------------------------------------------------------------------------
- This file is part of the Microsoft NGWS Samples.
-
- Copyright (C) 1998-2000 Microsoft Corporation. All rights reserved.
- ==========================================================================+*/
-
- using System;
- using System.WinForms;
- using System.WinForms.Design;
-
- public class DataEdit : TextBox
- {
- /*****************************************************************************
- Function : Append
-
- Abstract: Appends a string to the end of the edit control
-
- Input Parameters: str(String)
-
- Returns: void
- ******************************************************************************/
- public void Append(String str)
- {
- int len = Text.Length;
- SelectionStart = len;
- SelectionLength = len;
- SelectedText = str;
- }
-
- /*****************************************************************************
- Function: TruncateOneCharFromEnd
-
- Abstract: Truncates one character from the end of the text in the edit
- control.
-
- Input Parameters: (none)
-
- Returns: void
- ******************************************************************************/
- public void TruncateOneCharFromEnd()
- {
- int len = Text.Length;
- if (len == 1) {
- Text = "";
- } else if (len > 1) {
- SelectionStart = len-1;
- SelectionLength = len;
- String s = SelectedText;
- if (s.Equals("\n")) {
- SelectionStart = len-2;
- SelectionLength = len;
- }
- SelectedText = "";
- }
- }
-
- }
-