>> [...]
>>> You can, however, achieve the padding by overriding OnTextBoxChanged
[quoted text clipped - 9 lines]
>handling the connection between the value and the displayed text
>yourself. Just put a TextBox and a couple of buttons together yourself.
Are you saying to have three controls on the form, a TextBox and two
Buttons? Or are you saying to create a UserControl that inherits from
the TextBox control and add a couple of buttons to it?
I would prefer the latter as it makes for a contorl that is easily
used in other projects. I looked into this briefly and cannot seem to
get the buttons to appear. The UserControl Designer looks different
from a Form Designer, and I have used code in the Form Designer to
figure out how to dynamically add controls to a form. And I have used
a UserControl that inherits from the NumericUpDown that adds rollover
and rollunder functionality, but I am having problems adding other
controls, like a couple of buttons to a TextBox.
Can you point me to a resource that can help with this understanding?
I have already done a Google search and checked with CodeGuru and
CodeProject with no luck.
>However, in the spirit of the hacking, I'll suggest that the above
>technique _might_ work if you protect the assignment with a flag that
[quoted text clipped - 20 lines]
> }
> }
I tried this and it doesn't seem to work.
>The reason I say "_might_" is that I don't know off the top of my head
>what kinds of things the control does when you set the Text property. I
[quoted text clipped - 3 lines]
>
>Pete
Peter Duniho - 19 Mar 2008 00:52 GMT
> Are you saying to have three controls on the form, a TextBox and two
> Buttons? Or are you saying to create a UserControl that inherits from
> the TextBox control and add a couple of buttons to it?
The latter, as you prefer. The NumericUpDown control (ultimately)
inherits from ContainerControl, rather than UserControl. If you didn't
need anything that UserControl added (and you probably don't), then you
could just inherit from ContainerControl. But using UserControl does
provide Designer support for layout out the control, so that may be
preferable.
> I would prefer the latter as it makes for a contorl that is easily
> used in other projects. I looked into this briefly and cannot seem to
> get the buttons to appear.
Well, normally it "just works". It's not much different from designing a
Form...there's just no title bar, etc.
> The UserControl Designer looks different
> from a Form Designer, and I have used code in the Form Designer to
> figure out how to dynamically add controls to a form. And I have used
> a UserControl that inherits from the NumericUpDown that adds rollover
> and rollunder functionality, but I am having problems adding other
> controls, like a couple of buttons to a TextBox.
I don't understand what you mean by "a UserControl that inherits from the
NumericUpDown". That's not possible, since both are already classes in
.NET and C# doesn't support multiple inheritance. You can't have a class
that inherits both UserControl and NumericUpDown.
> Can you point me to a resource that can help with this understanding?
> I have already done a Google search and checked with CodeGuru and
> CodeProject with no luck.
Unfortunately, I don't have any specific leads. I've never had any
trouble using the VS Designer to create a UserControl. If you have tried
and have some specific thing that's not working for you, we can try to
offer advice here. But it's really fairly simple, and so it doesn't
surprise me that there's no obvious reference to walk you through it. If
you know how to use the Designer generally, then creating a
UserControl-derived class is pretty much the same.
Pete