NumericUpDown Image help

mechwarrior3

Well-known member
Joined
Dec 19, 2005
Messages
67
Programming Experience
Beginner
Hello, everyone. I've very recently begun using VB .NET and these forums have already been incredibly helpful in converting some of my VB6 code to VB .NET.

Onto my question: I need to use a numericupdown control. However, I need the up/down buttons to be bigger. How can I resize those? These buttons need to be resized because this form I'm designing will be used as a touchscreen so the buttons need to be big. Is there any way to resize those buttons specifically. I've seen how to resize the overall control, but the buttons stay the same size. Only the textbox seems to change size.

If there is no way to resize those buttons, is there another way to do this? The way I am doing this right now in VB6 is with a text box and a spin button. Is there a spin button equivalent in VB .NET?

Any help would be greatly appreciated. Thank you for your time. :)
 
Like most one-line controls the height of a NumericUpDown is controlled by the Font.Size property. Your post indicates that you may already be aware that this will affect the height of the arrow buttons but not the width. You could use a VScrollBar but then you can control the width but not the height of the buttons. You may well be able to owner-draw the control and make the arrow buttons whatever size you like. There is no spin button control in the .NET Framework but you cou
ld quite easily create your own with a UserControl containing two regular Buttons. You may also be able to find a third-party control that will do what you want.
 
Okay, I shall try to create a user control or just make two buttons per text box that will be tied to the text box and will have an image of each arrow on it or something. However, I am lazy so I shall also check for third party buttons that can do what I am looking for. ;)

Thank you for your help jmc. Also, sorry about posting in the wrong forum.

So this is what I am doing to solve the problem: Just going to create two separate buttons with the proper images of an up arrow and a down arrow drawn on them. Their click events will be tied to a single textbox. The textbox will just display a number that will be incremented or decremented by each button click. I'm also going to research if there is a way to create a kind "class" that will include all three controls and their behavior. That's probably that UserControl that you were talking about, right jmc?

There is one annoying part to this solution. I have to resize the images in paint. I can't seem to get VB .NET's windows forms editor to allow me to resize the image from there. Oh well. It's a solution in any case. :)
 
Last edited:
A UserControl is basically a container for other controls that then behave as a single unit. This means that you can hide the individual controls as private members and just expose public properties and members of the UserControl itself, plus you can reuse the unit whenever and wherever you like. UserControl is one of the options on the Add item of the Solution Explorer context menu.

As for your arrows, you may be better off drawing them on demand using GDI+ rather than using existing images. That way you can easily scale them to the current size of the button each time they get drawn. That's assuming that you want the buttons to be able to be resized, which seems logical.
 
Back
Top