How to stretch a ToolStripProgressBar?

T

Tim_Mac

hi,
i'm very impressed with the new ToolStrip controls. but one thing i
can't seem to do is get the ToolStripProgressBar to stretch with the
form, like anchor=bottom | left | right.
i like to have a good wide progress bar, but perhaps this isn't ever
necessary? i know i could do it in code based on the width of the form
window, but that certainly isn't elegant, just to get the thing to size
up and down with the form like normal controls can do via the anchor
settings.

has anyone found a way to do this? autosize doesn't seem to have any
effect.
thanks for any tips
tim
 
J

james

Tim, I just tried putting a Progressbar on a Toolstrip and set it's Anchor Properties to : Left,Top, & Right and then ran the
app and the progressbar resized as I resized the form. It did stay the same (relative) distance from the right side of the form
from the intial settings I gave it in the Forms Designer. I don't think you need Autosize for it to work. (unless, I have
misunderstood what you are trying to do)
james
 
J

Jeffrey Tan[MSFT]

Hi Tim,

Thanks for your post.

Yes, the similiar issue has been reported by other customer to our product
team. Actually this behavior is by design. Please refer to the link below:
"Bug Details: ToolStripTextBox.Dock has no effect"
http://lab.msdn.microsoft.com/ProductFeedback/viewFeedback.aspx?feedbackid=4
b664183-f323-48cb-bcc1-c5d6c155dd25

If you use the workaround provided by that link: such as changing the
ToolStrip.LayoutStyle to Table, then it should work for you.

Hope this helps

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
T

Tim_Mac

hi james. my progress bar doesn't have an Anchor property. are you
sure you have a ToolStripProgressBar and not just a normal ProgressBar
dropped on top of a ToolStrip?
 
T

Tim_Mac

hi Jeffrey, thanks for your reply. i see this would work for a text
box or label in a ToolStrip. but the ToolStripProgressBar doesn't have
a Spring property.
the Toolstrip is already on Table layout.
any other ideas? short of overlaying a regular ProgressBar on the
ToolStrip?
thanks
tim
 
J

james

Sorry Tim, I was using a regular ToolStrip control and dropping a ProgressBar on it.
That is probably why it worked for me. (teach me to not read a post closer)
james
 
J

Jeffrey Tan[MSFT]

Hi Tim,

Thanks for your feedback.

Spring is the auto stretch property only ToolStripStatusLabel have. For
normal ToolStrip, we have to use Table layout. In your project, is your
ToolStrip embed in a ToolStripContainer?

Normally, if we drop a ToolStrip control on the form designer, its Dock
property will default be DockStyle.Top, which causes the ToolStrip attach
to the top as a menu style. In this situation, if we change its into table
layout, then add a ToolStripProgressBar, then the statement should take
effect:
private void Form1_Load(object sender, EventArgs e)
{
this.toolStripProgressBar1.Anchor = AnchorStyles.Right;
}
It works on my test project.

If your ToolStrip is embeded in the ToolStripContainer, defaultly, it will
be in the Top panel of the ToolStripContainer, which our dock/anchor
setting will take no effect. So we should drop it into the
ToolStripContainer.ContentPanel, then setting ToolStripContainer's Dock or
Anchor property. For example, in my test sample, I set ToolStripContainer's
Anchor property to Top|Left|Right|Buttom, then the ToolStripContainer will
have consistent scale with the form. After dragging the ToolStrip into the
ContentPanel of ToolStripContainer, I set ToolStrip.Dock to Fill, with
ToolStripProgressBar.Dock to right. Then the ToolStripProgressBar will go
with the form size change

Hope this helps

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

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