views:

521

answers:

1

Is there a reasonably simplistic way to combine a trackbar with a progress bar? What I'd like to be able to accomplish it so that the progressbar only goes up to the trackbar when a button is clicked. This is mainly for learning purposes but would be nice to know how to use it in a practical way as well.

Thanks in advance.

[edit] Like this. http://www.java2s.com/Tutorial/VB/0260%5F%5FGUI/LinkProgressBarwithaTrackBar.htm

But inside of each other, or combined, instead of next to each other.

A: 

Not sure what you mean, exactly, but you could put a TrackBar and a ProgressBar into a single custom UserControl (one above the other, for example).

Update: since you want them combined instead of one of top of the other, your best bet is just to write your own UserControl from scratch.

Update 2: Click here to see an application with a simple UserControl that combines the TrackBar and the ProgressBar concepts (move the slider to change the track bar's value, and click the "Show Progress" button to show how the progress bar goes from zero to wherever the thumb of the track bar is). Click here to download the source code.

MusiGenesis
How would I do this? I've never done a UserControl.
Nyight
Basically, you right-click on your project, then click "Add | User Control". A UserControl is kind of like a form, but with no window controls (titlebar, close buttons etc.). You can add other basic controls to it (like a TextBox, Button etc.) and encapsulate the desired behavior, and then use it on a form just like any other control. Here's an example for a UserControl that is a progress bar with a gradient color, to get you started: http://www.codeguru.com/csharp/csharp/cs_syntax/componentdevelopment/article.php/c15147
MusiGenesis
Is there anyway I could contact you directly if I need any more help? Like a forum or something? Granted you probably won't want to give out any personals so that's fine.
Nyight
@Nyight: I'll create a sample control that does what you need and post it here in a little while, and then you can modify it as necessary. I think the TrackBar is the second most-hideous control in Windows (after the NumericUpDown control), so I'm always happy to stick another dagger in its heart.
MusiGenesis
@Nyight: feel free to incorporate this control in your application, and modify it however you like. You might want to add the scale marks and pointed button like in the normal TrackBar, although these are the parts of the TrackBar that I think are the ugliest, and also doing a pointed button (instead of a square one) is pretty tricky.
MusiGenesis
@Nyight: I can be contacted via the website in my profile, or you can just ask additional questions on StackOverflow, and I'll see them.
MusiGenesis