I want to select all the text of a System.Windows.Forms.TextBox() control in a GotFocus event, but all the examples I found make use of the .SelectionStart / .SelectionEnd properties of the control, and those aren't available in .NET 2.0 Framework.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
namespace xCustomControls
{
public partial class xTextBox : System.Windows.Forms.TextBox
{
public xTextBox()
{
InitializeComponent();
this.GotFocus += new System.EventHandler(this.GotFocusHandler);
}
private void GotFocusHandler(object sender, EventArgs e)
{
Control ctrl = (Control)sender;
ctrl.BackColor = Color.Cyan;
ctrl.SelectionStart = 0;
}
Error:
'System.Windows.Forms.Control' does not contain a definition for 'SelectionStart' and no extension method 'SelectionStart' accepting a first argument of type 'System.Windows.Forms.Control' could be found (are you missing a using directive or an assembly reference?)
Any ideas?
TIA, Pablo