Results 1 to 10 of 10

Thread: "sticky" Toolstrip

  1. #1

    Thread Starter
    Frenzied Member jdc20181's Avatar
    Join Date
    Oct 2015
    Location
    Indiana
    Posts
    1,168

    "sticky" Toolstrip

    In HTML/CSS, you can force a toolstrip/menu to stay on the page while scrolling through content. Essentially I am looking to achieve this same effect. Could someone help me out on achieving this?
    Disclaimer: When code is given for example - it is merely a example.




    Unless said otherwise indicated - All Code snippets advice or otherwise that I post on this site, are expressly licensed under Creative Commons Attribution 4.0 International Please respect my copyrights.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,350

    Re: "sticky" Toolstrip

    Just put the content in a different container, e.g. add a ToolStrip and a Panel to your form and then put the rest of your controls on the Panel. It would then be the Panel that would scroll so the ToolStrip would be unaffected.

  3. #3

    Thread Starter
    Frenzied Member jdc20181's Avatar
    Join Date
    Oct 2015
    Location
    Indiana
    Posts
    1,168

    Re: "sticky" Toolstrip

    Quote Originally Posted by jmcilhinney View Post
    Just put the content in a different container, e.g. add a ToolStrip and a Panel to your form and then put the rest of your controls on the Panel. It would then be the Panel that would scroll so the ToolStrip would be unaffected.
    Trying to avoid using panels as its causing issues with resizing controls on my form.
    Disclaimer: When code is given for example - it is merely a example.




    Unless said otherwise indicated - All Code snippets advice or otherwise that I post on this site, are expressly licensed under Creative Commons Attribution 4.0 International Please respect my copyrights.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,350

    Re: "sticky" Toolstrip

    Quote Originally Posted by jdc20181 View Post
    its causing issues with resizing controls on my form.
    There's no reason that should be the case so I can only assume that whatever you did, you did wrong. You should start another thread for that issue.

  5. #5

    Thread Starter
    Frenzied Member jdc20181's Avatar
    Join Date
    Oct 2015
    Location
    Indiana
    Posts
    1,168

    Re: "sticky" Toolstrip

    Quote Originally Posted by jmcilhinney View Post
    There's no reason that should be the case so I can only assume that whatever you did, you did wrong. You should start another thread for that issue.
    Not really, I want to use the scrollbars on the form, not the RTB, so in order to do that the RTB has to be on the form not in a panel, or it don't work.
    Code:
        Private Sub Form1_SizeChanged(sender As Object, e As EventArgs) Handles MyBase.SizeChanged
            RichTextBox1.Location = New Point(Me.Width \ 2 - RichTextBox1.Width \ 2, Me.Height \ 2 - RichTextBox1.Height \ 2)
            If Me.WindowState = FormWindowState.Maximized Then
                RichTextBox1.Size = New Size(RichTextBox1.Height + 30, RichTextBox1.Width)
    
            End If
        End Sub
    Disclaimer: When code is given for example - it is merely a example.




    Unless said otherwise indicated - All Code snippets advice or otherwise that I post on this site, are expressly licensed under Creative Commons Attribution 4.0 International Please respect my copyrights.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,350

    Re: "sticky" Toolstrip

    Quote Originally Posted by jdc20181 View Post
    Not really, I want to use the scrollbars on the form, not the RTB, so in order to do that the RTB has to be on the form not in a panel, or it don't work.
    It works if you do it properly. Maybe you should actually explain what you're trying to achieve. That would provide the best chance of our being able to help you achieve it. It's likely that you don't actually need any code to position and size your RichTextBox, with or without a Panel. That sort of thing can be more difficult in Windows Forms than WPF with a very complex layout but it doesn't appear that yours is especially complex. Using the Anchor and/or Dock properties of child controls and FlowLayoutPanel and/or TableLayoutPanel containers allows you to achieve quite a bit. For instance, it appears that you want your RichTextBox to remain the same width all the time and be centered in the form. You can achieve that using a TableLayoutPanel with its Dock property set to Fill. You can add 3 columns and 3 rows, set the width/height of the first and last to 50% and the middle to auto-size. You can then add the RichTextBox to the centre cell. Now, you can resize the form as much as you like and the TableLayoutPanel will always fill the whole form and the RichTextBox will always remain in the centre of it.

    Now, try providing a FULL and CLEAR explanation of what you're trying to achieve. Expecting us to provide a solution to a problem that we only know small parts of will generally not end well.

  7. #7

    Thread Starter
    Frenzied Member jdc20181's Avatar
    Join Date
    Oct 2015
    Location
    Indiana
    Posts
    1,168

    Re: "sticky" Toolstrip

    Ok, so I am working on a Notepad Feature for a larger project, and I am making improvements to create a better experience, and "Material" design of sorts, I don't do designing very good, so I have a project partner that will come through and make it look nice, but anyways here is what I have been testing.

    IMAGE 1: https://gyazo.com/b7c235a56d1677b86270a10d19afac61

    In IMAGE 1, you will see the top of a decently oversized RichTextBox which is AUTOMATICALLY resized based on the Text content , with ALL Scrollbars false. Rather, the Scroll bars you see are on the form If I were to do the following:

    Just put the content in a different container, e.g. add a ToolStrip and a Panel to your form and then put the rest of your controls on the Panel. It would then be the Panel that would scroll so the ToolStrip would be unaffected.
    I would NOT be able to use the default Scrollbars,OR resize the RTB because it is restricted to its parent container. And even IF I resize the parent container (a panel for example), it is not being respected. I have Tried to use a panel.

    So I ditched the panel altogether.

    What I am Trying to accomplish is keep the Toolstrip in IMAGE 1 when you scroll.

    As Shown Below in IMAGE 2

    https://gyazo.com/1a2ed49e5a837c4106a4e70193bd3e19


    I tried also with the tablelayoutpanel and it was not the results I was looking for.

    Right now my only problem is getting the Toolstrip to stay when you scroll on the form.

    By manually keeping the positions, instead of using panels or Tablelayoutpanels I have more control of the RTB.
    Disclaimer: When code is given for example - it is merely a example.




    Unless said otherwise indicated - All Code snippets advice or otherwise that I post on this site, are expressly licensed under Creative Commons Attribution 4.0 International Please respect my copyrights.

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,350

    Re: "sticky" Toolstrip

    Good grief! Add the ToolStrip to the form, then add the Panel to the form and set its Dock property to Fill, then put everything that you would have put on the form into the Panel. With AutoScroll set to True (which it may be by default, not sure) the Panel will behave EXACTLY the way the form would and the ToolStrip will stay where it is when you scroll. Simple stuff. If you were to actually explain how the RichTextBox is supposed to be resized (that would fall under "FULL and CLEAR explanation") then we can help you with the specifics of that too. If you actually provide us with the relevant information, you might be surprised what we can tell you.

  9. #9

    Thread Starter
    Frenzied Member jdc20181's Avatar
    Join Date
    Oct 2015
    Location
    Indiana
    Posts
    1,168

    Re: "sticky" Toolstrip

    Ok, I have been about as clear as I can be. I have been doing this for almost 6 years. I understand what you can do with a freaking panel I clearly stated I do not want to use panels. Period. No big long argument necessary. If that is the only solution, then that is one thing otherwise, it is not what I am after.
    Disclaimer: When code is given for example - it is merely a example.




    Unless said otherwise indicated - All Code snippets advice or otherwise that I post on this site, are expressly licensed under Creative Commons Attribution 4.0 International Please respect my copyrights.

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,350

    Re: "sticky" Toolstrip

    Yes, you have stated that you don;t want to use a Panel, but the reason you don;t want to use a Panel is nonsense. It's your prerogative though. I'm not going to spend my time trying to find another solution when there's an obvious one being rejected though.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width