I have 3 textbox for hour,minutes and seconds and one Vscrolbar for up and down values .I am making an interface of selection of time similar to system time on windows.If user will select Hou开发者_JS百科r textbox and again he will click on Vscrollbar to upward then my hour text values should be increase and same for second and minutes.How will i do this.Another concept will also be ok. I am working with C# windows.net.
Use NumericUpDown
control instead of useing TextBox
and ScrollBar
. It has all the things you need.
When the user clicks the scrollbar, it gets the focus, so you need to track which control (hour,minute,second) was clicked last. It would also be a good idea to let the user know which control is the active one (for example by changing its background color).
Then you just subscribe to the scrollbar-event, check with your private member variable which control is the active one and change its value.
You may also want to set the scroll-range according to the active control, so for example if hours is active, set the scroll range from 0 to 24 and set the current position according to the current hour. That way you will get "ready-to-use" values from the scroll event.
精彩评论