Sign in to follow this  

[.net] C# Trackbar Control

This topic is 3487 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I've got a trackbar slider in my XNA/winforms editor for use with my custom animation editor suite.. The issue I have is I would like to draw markers/icons on to the trackbar to specify where along the timeline keyframes have been set & also draw text underneath the ticks to specify the time intervals.. I haven't done any custom controls with WinForms before & so I was wondering how I would go about creating a custom trackbar which will allow me to add these specific features to the control..? Any help would be much appreciated! Thanks!

Share this post


Link to post
Share on other sites
The easiest way would probably be to create a subclass of TrackBar and override the OnPaint method. By calling base.OnPaint first and then drawing your custom stuff over it, you can take advantage of the basic TrackBar functionality so you only have to add code for your specialized features.

Hope this helps :)

Share this post


Link to post
Share on other sites

Well, if you want to render complete WinForms controls on top of the TrackBar, you're probably better off using a container (like a Panel) and arranging your controls over eachother as you want. This should allow you to have the panel take care of the focus stuff and the troubles of handling user input.

Overriding OnPaint like I suggested is mainly useful if you want to extend the functionality of a given control, like adding tick labels and drawing special keyframe ticks. You can use the Graphics object suppied in the PaintEventArgs to draw all kinds of shapes based on the data you have. It is a bit lowlevel, so it can take some extra work to deal with the layout and drawing complexer things, but rereading your post I think this would still be the way to go.

I don't know wxWidgets, but I took a quick look on Google and it seems similar to what the Graphics object allows you to do in .NET. I may be way of here though [smile]

Share this post


Link to post
Share on other sites

This topic is 3487 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this