Solved

Mimick Spring on ToolStrip

Posted on 2006-07-19
7
944 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
  • 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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 to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
This video discusses moving either the default database or any database to a new volume.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now