Wild stab in the dark guess of what you want is, to highlight the currently selected index text and if the selected index is changed then the new text should be all highlighted.
If this is right then just use the
SelectedItemChanged
event such as;
domainUpDown1.SelectedItemChanged += new EventHandler(domainUpDown_SelectedItemChanged);
Then in the event handler;
void domainUpDown_SelectedItemChanged(object sender, EventArgs e)
{
DomainUpDown control = sender as DomainUpDown;
control.Select(0, control.Text.Length);
}
The only problem is that when the control looses focus the highlighting will disappear, there is nothing you can do to stop that but if you also use the
Click
and
GotFocus
events you can re-highlight the text when the control receives focus again.
domainUpDown1.Click += new EventHandler(domainUpDown_Click);
domainUpDown1.GotFocus += new EventHandler(domainUpDown_GotFocus);
And the event handlers;
void domainUpDown_Click(object sender, EventArgs e)
{
DomainUpDown control = sender as DomainUpDown;
control.Select(0, control.Text.Length);
}
void domainUpDown_GotFocus(object sender, EventArgs e)
{
DomainUpDown control = sender as DomainUpDown;
control.Select(0, control.Text.Length);
}
If the TabIndex of your DomainUpDown control is 0 (zero) then it will highlight on form load but if it is not then is will not as it will not gain focus.