views:

574

answers:

3

I'm using a progress bar to display the battery status. If the user clicks on the progress bar i want to display a popup with details.

Excluding the solution that requires checking if the click coordonates is in the bounds of the progress bar has anyone found another solution or a workaround to this?

A: 

I've always just written my own custom ProgressBar usercontrol. It takes maybe 5 minutes to write, and the built-in progress bar control looks like ass anyway.

I think it might be possible to use Reflection for this, but it would easier to just write your own control.

Update: I just tried casting the ProgressBar as a Control (which does have a Click event) and then assigning an event handler in code, but this does not appear to work.

MusiGenesis
I haven't used Compact framework at all, but it might be possible to create a derived control which simply overrides OnClick() to raise a custom event.
Groo
I'm not to eager to create a custom control and use it only once, but it seems the only way to go. Anyway, i'll wait a few days to see if someone comes with another solution otherwise i'll accept this as an answer. Hell, more than half of the controls in my app are custom.
Fiur
+1  A: 

Also, it's generally considered good form to only use controls in the way that users are accustomed to. Progress bars are meant (and traditionally used) only to display information. This is why they removed all the interaction events in Compact Framework.

I think a better approach would be to leave the progress bar as it is, and add a "Details" LinkLabel above or next to the bar.

MusiGenesis
I disagree with you on this one. I think it depends on how you educate your users also, i mean when the progress bar that shows a battery is in an toolbar area among other clickable things i think it's obvious users will try to click it, if not consider it an easter egg .A Details Label wouldn't be a good ideea and i don't have any space also.
Fiur
+1  A: 

OK, an easier way to do the custom control is to just start with a UserControl, drop a ProgressBar on it and dock it so that it fills the UserControl, then expose the ProgressBar as a public property of the UserControl, so that your code would say

myProgressBar1.ProgressBar.Max = 100

instead of

progressBar1.Max = 100

Then just use the Click event of the usercontrol to show the details (I think you might have to disable the inner ProgressBar for the click to work, but that shouldn't affect the appearance of the progress bar).

This way your user control looks exactly like a regular progress bar (and, hence, like ass). :)

MusiGenesis