windows mobile - How to programmatically select all the text of a TextBox control (Compact .NET 2.0) -
I want to select all the text of a system. Windows.Forms.TextBox () controls in a GotFocus event, but use all the examples I have found. Selection Start / The selected properties of control, and they are not available in the .NET 2.0 framework.
using the system; Using System.Collections.Generic; Using System.ComponentModel; Using System.Drawing; Using System.Data; Using System.Text; Using System.Windows.Forms; Name space xCustomControls {public partial class xTextBox: System.Windows.Forms.TextBox {public xTextBox () {InitializeComponent (); This.GotFocus + = New System. EventHandler (this.GotFocusHandler); } Private Zero GotFocusHandler (Object Sender, EventArgs e) {Control ctrl = (Control) Sender; Ctrl.BackColor = Color.Cyan; Ctrl.SelectionStart = 0; }
Error:
There is no definition for 'SelectionStart' in 'System.Windows.Forms.Control' and no extension method 'SelectionStart' accepts the first argument Does not
Any ideas?
TIA, Pablo
>
Replace the line
control ctrl = (control) sender;
with
text box ctrl = (textbox) sender;
The compiler thinks that you are working with a control class, which does not have section start, but your object is actually a derivative which does that.
Comments
Post a Comment