have the same problem but am using vb.net ...is there any solution for my problem... am new in vb.net...if there is a solution for me pls answer my question clear:P sorry for my bad english:(((
I trying to do the same thing. I tried Enter and GotFocus event so that when user click on the numeric control, I try numericupdown.select(1,3) for example but it did not work.
Do you have a solution already I understand from what you want is like doubleclicking, the value will be highlighted, ready for overwrite. This is the same as what I need.
I think I may not ahve been clear. What I am looking to do is, highlight the contents of the controls once the user either tabs into the field or enters it by clicking on it. Just the way we can highlight the contents of a textbox, by setting it's SelectionStart and Selection lenght properties, I was looking at a way to do similar thing in NUmeric UpDowm control.
Hi, This just mimics the behaviour I want, but does not simulate it. When I use the code you suggested in the Enter and Leave events, the controls change color as desired, but that's about it. What I want it to do is when I start typing in it should override the existing data, and if I go to the end then it should start appending the data. I can do it with some coding...I was seeing if there are some properties I could set that would do this for me.
That's a working solution. You can simplify it slightly by not casting the NumericUpDown to UpDownBase. There's no need to cast it to the base class to call base class members.
// In your reusable subroutine, set a reference to the UpDownBase interface - this is a superclass of the NumericUpDown control. It is on this interface that you will execute the Select method to highlight your text. Enhance at your leisure.
NumericUpDown Controls...how to select the text when it gets the focus
tabish
have the same problem but am using vb.net ...is there any solution for my problem... am new in vb.net...if there is a solution for me pls answer my question clear:P sorry for my bad english:(((
thanks
Sajid Saeed
private void numericUpDown1_Enter(object sender, System.EventArgs e)
{
numericUpDown1.ForeColor = Color.Yellow;
numericUpDown1.BackColor = Color.Blue;
}
private void numericUpDown1_Leave(object sender, System.EventArgs e)
{
numericUpDown1.ForeColor = Color.Black;
numericUpDown1.ForeColor = Color.White;
}
Ananda85
Kelly Stich
I trying to do the same thing. I tried Enter and GotFocus event so that when user click on the numeric control, I try numericupdown.select(1,3) for example but it did not work.
Do you have a solution already I understand from what you want is like doubleclicking, the value will be highlighted, ready for overwrite. This is the same as what I need.
Vincent
Nexus_019
muku
private void numericUpDown1_ValueChanged(object sender, System.EventArgs e)
{
MessageBox.Show( numericUpDown1.Value.ToString() );
}
BloomyMB
This just mimics the behaviour I want, but does not simulate it. When I use the code you suggested in the Enter and Leave events, the controls change color as desired, but that's about it. What I want it to do is when I start typing in it should override the existing data, and if I go to the end then it should start appending the data. I can do it with some coding...I was seeing if there are some properties I could set that would do this for me.
Thanks for your help.
Dan.G
That's a working solution. You can simplify it slightly by not casting the NumericUpDown to UpDownBase. There's no need to cast it to the base class to call base class members.
public Form1()
{
InitializeComponent();
numericUpDown1.Enter += new EventHandler(numericUpDown1_Enter);
}
void numericUpDown1_Enter(object sender, EventArgs e)
{
numericUpDown1.Select(0, numericUpDown1.Text.Length);
}
Souhail
For all who encounter this problem after I did , may this work for you also:
// Wire up your event for when the control receives focus in your form initialization section
this.numericUpDownControl.Enter += new System.EventHandler(this.numericUpDownControl_Enter);
// In your event handler, call your reusable subroutine to select the text
private void numericUpDownControl_Enter(object sender, System.EventArgs e)
{
SelectAllText(numericUpDownControl);
}
// In your reusable subroutine, set a reference to the UpDownBase interface - this is a superclass of the NumericUpDown control. It is on this interface that you will execute the Select method to highlight your text. Enhance at your leisure.
private void SelectAllText(NumericUpDown nudControl)
{
UpDownBase udb = (UpDownBase)nudControl;
udb.Select(0, udb.Text.Length);
}
RS
Adrian West
Goswinus
Holy cow, how did I miss that!
Thanks for that catch, Yifung - I'm off to find some NoDoz...
RS