Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Mimick Spring on ToolStrip

Posted on 2006-07-19
7
Medium Priority
?
985 Views
Last Modified: 2012-08-13
I was trying to figure out how to span a control on the ToolStrip to expand to fill the entire ToolStrip (with other controls on it as well), similar to AutoSize=Spring for the StatusStrip.

So what I did is similar to the following:

Control.Width = ToolStrip.Width - ToolStrip.Padding.Horizontal - ToolStrip.Margin.Horizontal - (the other widths of the controls)
(BTW, grip is invisible)

Even then, it still overflows and I have to subtract by an arbitrary number to get it to fit...

Am I missing something?

Chris
0
Comment
Question by:khooc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17139906
Chris,

I don't totally understand what you need.  Is the control at the far right of the ToolStrip?

Bob
0
 

Author Comment

by:khooc
ID: 17158965
Hi

I mean if you have a docked toolstrip, and I place a textbox on it, how can I make it so that the textbox's width is the same as the toolstrip without overflowing (also with other controls on the toolstrip as well)?

Chris
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17160234
Chris,

How many controls on the ToolStrip?  Do you want it to spring from the controls location to the fill the rest of the ToolStrip?

Bob
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 

Author Comment

by:khooc
ID: 17162010
A variable number of controls...

> Do you want it to spring from the controls location to the fill the rest of the ToolStrip?
Yep, pretty much... basically something that mimicks the Spring property.

Chris
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 1000 total points
ID: 17191241
I tried something like this:

Public Class formToolStrip

  Private Sub formToolStrip_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    Me.combo1.AutoSize = False
    Me.combo1.Width = Me.ToolStrip1.ClientSize.Width - Me.GetToolItemLeft(Me.combo1) - Me.ToolStrip1.OverflowButton.Width - Me.ToolStrip1.Padding.Left - Me.ToolStrip1.Margin.Left

  End Sub

  Private Function GetToolItemLeft(ByVal item As ToolStripItem)

    Dim left As Integer
    For Each search As ToolStripItem In Me.ToolStrip1.Items
      If search IsNot item Then
        left += search.Width
      End If
    Next

    Return left
  End Function
End Class

Bob
0
 

Author Comment

by:khooc
ID: 17198582
That works, thanks very much :-)  I just had to turn CanOverflow to False to prevent the overflow button from showing.

Chris
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17200133
Chris,

You also have to get the size of the button right, even when CanOverflow = False.

Bob
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question