471,627 Members | 1,152 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,627 software developers and data experts.

Numeric UpDown

Hello
I would like to set a NumericUpDown control to readonly and I don't want
it to response on klicks on the arrows.
I set the ReadOnly property to false and the InterceptArrowKeys to false
too.

myNumericUpDown.ReadOnly = false;
myNumericUpDown.InterceptArrowKeys = true;

The result is that the control looks like ReadOnly but the arrow buttons
still work and can change the value. And I think this shouldn't be
possible.

Thanks
Ferdinand
Dec 15 '05 #1
9 2872
myNumericUpDown.Enabled = false ???

Dec 15 '05 #2
>From the documentation for UpDownBase.ReadOnly:

"true if the text can be changed by the use of the up or down buttons
only; otherwise, false. The default value is false."

"By setting the ReadOnly property to true, you will eliminate the need
for much validation of the Text property. The user will be restricted
to the use of the up and down buttons to change the Text values. It
will only allow them to select values you specify."

So, basically, the ReadOnly property doesn't do what you think it does
(or, for that matter, what the name implies that it does... stupid
behaviour for a property named ReadOnly, IMHO, but there you go).

Dec 16 '05 #3
But with InterceptArrowKeys set to false it is still changable with the
Arrowkeys.
I don't want to Use enabled=false becuase then you cannot copy the
number to paste it somewhere else.

Thanks
Ferdinand

Bruce Wood wrote:
From the documentation for UpDownBase.ReadOnly:


"true if the text can be changed by the use of the up or down buttons
only; otherwise, false. The default value is false."

"By setting the ReadOnly property to true, you will eliminate the need
for much validation of the Text property. The user will be restricted
to the use of the up and down buttons to change the Text values. It
will only allow them to select values you specify."

So, basically, the ReadOnly property doesn't do what you think it does
(or, for that matter, what the name implies that it does... stupid
behaviour for a property named ReadOnly, IMHO, but there you go).

Dec 16 '05 #4
But with InterceptArrowKeys set to false it is still changable with the
Arrowkeys.
I don't want to Use enabled=false becuase then you cannot copy the
number to paste it somewhere else.

Thanks
Ferdinand

Bruce Wood wrote:
From the documentation for UpDownBase.ReadOnly:


"true if the text can be changed by the use of the up or down buttons
only; otherwise, false. The default value is false."

"By setting the ReadOnly property to true, you will eliminate the need
for much validation of the Text property. The user will be restricted
to the use of the up and down buttons to change the Text values. It
will only allow them to select values you specify."

So, basically, the ReadOnly property doesn't do what you think it does
(or, for that matter, what the name implies that it does... stupid
behaviour for a property named ReadOnly, IMHO, but there you go).

Dec 16 '05 #5
But with InterceptArrowKeys set to false it is still changable with the
Arrowkeys.
I don't want to Use enabled=false becuase then you cannot copy the
number to paste it somewhere else.

Thanks
Ferdinand

Bruce Wood wrote:
From the documentation for UpDownBase.ReadOnly:


"true if the text can be changed by the use of the up or down buttons
only; otherwise, false. The default value is false."

"By setting the ReadOnly property to true, you will eliminate the need
for much validation of the Text property. The user will be restricted
to the use of the up and down buttons to change the Text values. It
will only allow them to select values you specify."

So, basically, the ReadOnly property doesn't do what you think it does
(or, for that matter, what the name implies that it does... stupid
behaviour for a property named ReadOnly, IMHO, but there you go).

Dec 16 '05 #6
But with InterceptArrowKeys set to false it is still changable with the
Arrowkeys.
I don't want to Use enabled=false becuase then you cannot copy the
number to paste it somewhere else.

Thanks
Ferdinand

Bruce Wood wrote:
From the documentation for UpDownBase.ReadOnly:


"true if the text can be changed by the use of the up or down buttons
only; otherwise, false. The default value is false."

"By setting the ReadOnly property to true, you will eliminate the need
for much validation of the Text property. The user will be restricted
to the use of the up and down buttons to change the Text values. It
will only allow them to select values you specify."

So, basically, the ReadOnly property doesn't do what you think it does
(or, for that matter, what the name implies that it does... stupid
behaviour for a property named ReadOnly, IMHO, but there you go).

Dec 16 '05 #7
But with InterceptArrowKeys set to false it is still changable with the
Arrowkeys.
I don't want to Use enabled=false becuase then you cannot copy the
number to paste it somewhere else.

Thanks
Ferdinand

Bruce Wood wrote:
From the documentation for UpDownBase.ReadOnly:


"true if the text can be changed by the use of the up or down buttons
only; otherwise, false. The default value is false."

"By setting the ReadOnly property to true, you will eliminate the need
for much validation of the Text property. The user will be restricted
to the use of the up and down buttons to change the Text values. It
will only allow them to select values you specify."

So, basically, the ReadOnly property doesn't do what you think it does
(or, for that matter, what the name implies that it does... stupid
behaviour for a property named ReadOnly, IMHO, but there you go).

Dec 16 '05 #8
But with InterceptArrowKeys set to false it is still changable with the
Arrowkeys.
I don't want to Use enabled=false becuase then you cannot copy the
number to paste it somewhere else.

Thanks
Ferdinand

Bruce Wood wrote:
From the documentation for UpDownBase.ReadOnly:


"true if the text can be changed by the use of the up or down buttons
only; otherwise, false. The default value is false."

"By setting the ReadOnly property to true, you will eliminate the need
for much validation of the Text property. The user will be restricted
to the use of the up and down buttons to change the Text values. It
will only allow them to select values you specify."

So, basically, the ReadOnly property doesn't do what you think it does
(or, for that matter, what the name implies that it does... stupid
behaviour for a property named ReadOnly, IMHO, but there you go).

Dec 16 '05 #9
Let's back up a second, here.

A read-only text box that the user can't modify is really just a
ReadOnly TextBox with some useless buttons beside it. Why, exactly, do
you want those useless buttons there?

The only thing that comes to my mind is that you want a value that the
user can change in some situations, but which is read-only in other
situations. If that's the case, then there's an easy solution.

Place _two_ controls that that place on your form. One, a NumericUpDown
control; the other, a TextBox with ReadOnly set to true. Populate both
with your value, all the time. When you want the user to be able to
manipulate the value, Hide() the TextBox and Show() the NumericUpDown
control. When you want it to be read-only, Show() the TextBox and
Hide() the NumericUpDown control.

If you really want to be clever, create a UserControl of your own that
contains a NumericUpDown control and a TextBox that act this way
depending upon the setting of the ReadOnly property on your
UserControl. Lots more work, though, as you have to reproduce the
public contract of the NumericUpDown in your UserControl.

I wouldn't bother trying to bend NumericUpDown to your will. Just play
tricks behind the scenes to use a different control in ReadOnly
situations.

Dec 16 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Travis Oliphant | last post: by
2 posts views Thread by Johannes Nix |Johannes.Nix | last post: by
4 posts views Thread by Gezeala 'Eyah' Bacu\361o II | last post: by
1 post views Thread by Qumer Mumtaz | last post: by
6 posts views Thread by M.A. Oude Kotte | last post: by
7 posts views Thread by Sheldon | last post: by
reply views Thread by robert | last post: by
13 posts views Thread by nishit.gupta | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.