Solved

Mimick Spring on ToolStrip

Posted on 2006-07-19
7
963 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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 

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 250 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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

749 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