Computing height of status bar panel

G

Guest

I'm embedding a progress bar control on one of the panels of my status bar (via the controls property). I can easily set the prog bar to the same width of the panel but setting its height equal to the status bar's makes it taller than its panel (and panel has no height property, AFAIK). Any elegant way of querying the height of a status bar panel. Of course, I can do simple trial-and-error but that won't be elegant at all for me. Thanks =)
 
T

Tim Wilson

One way to do this is to set the desired StatusBarPanel's "Style" to
"OwnerDraw". Then hook into the StatusBar's "DrawItem" event and the code
should look like the following.

private void statusBar1_DrawItem(object sender,
System.Windows.Forms.StatusBarDrawItemEventArgs sbdevent)
{
if ((sbdevent.Panel == this.statusBarPanel1) && (this.progressBar1.Bounds
!= sbdevent.Bounds))
{
this.progressBar1.Bounds = sbdevent.Bounds;
}
}

--
Tim Wilson
..Net Compact Framework MVP

jester said:
I'm embedding a progress bar control on one of the panels of my status bar
(via the controls property). I can easily set the prog bar to the same width
of the panel but setting its height equal to the status bar's makes it
taller than its panel (and panel has no height property, AFAIK). Any elegant
way of querying the height of a status bar panel. Of course, I can do simple
trial-and-error but that won't be elegant at all for me. Thanks =)
 
H

Herfried K. Wagner [MVP]

* =?Utf-8?B?amVzdGVy?= said:
I'm embedding a progress bar control on one of the panels of my status
bar (via the controls property). I can easily set the prog bar to the
same width of the panel but setting its height equal to the status bar's
makes it taller than its panel (and panel has no height property,
AFAIK). Any elegant way of querying the height of a status bar panel.

<URL:http://www.google.de/[email protected]>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top