Setting BackColor of TextBox in NumericUpDown control (PocketPC)

E

Eirik

Hi,

I try to set the backcolor property of a NumericUpDown control on PocketPC,
but cannot seem to get it to work.
What I try to achieve is to set a diferent color when to control has focus.
Easy enough with TextBoxes, but I'm strugling with the NumericUpDown
control.

The code I try to use is something like this (I've tried different indexes
in the control collection) :
private void numKM_GotFocus(object sender, System.EventArgs e)
{
NumericUpDown ctrl = (NumericUpDown)sender;
ctrl.Controls[1].BackColor = colFocus;
}
What happens is I get a 'System.ArgumentOutOfrangeException'.
Debugging shows that the Controls collection has Count of 0 on the ctrl
object...?

Being a beginner, I'm stuck.

How do I change the backcolor of the TextBox in the NumericUpDown control?

Regards :)
 
D

Daniel Moth

Your confusion originates from your assumption that numericupdown has
controls in it. It is one control. Try
ctrl.BackColor = colFocus

Cheers
Daniel
 
E

Eirik

Thanks for your reply.

I tried that first, but didn't work (in emulator). That's why I assumed it
had controls in it.
Turns out it works on the physical device when I deploy there, but still
fails in the emulator.

Regards :)
 
D

Daniel Moth

Check the version of the CF on the emulator and on the device. This was
probably not available prior to some service pack (which I presume your
device has).

Cheers
Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top