Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a form with an panel A and a trackbar. Inside panel A, i have a second panel B, and inside that panel B there are many textbox. I need that when moving the trackbar, it decreases panel B with all the textbox that are included in it.
I need that when moving the trackbar I increase the size of panel B, and all the components in it. As a Zoom effect.
I try change font size of form, but it did not work.
I use Visual Studio for it.


What I have tried:

private void trackBarMap_Scroll(object sender, EventArgs e)
        {
            float font = 14;
            float scroll = trackBarMapa.Value;
            float fontfinal = (font * scroll) / 100;
            panelB.Font = new Font("Microsoft Sans Serif", fontfinal);

            panelB.Height = (height * Convert.ToInt32(scroll)) / 100;
            panelB.Width = (width * Convert.ToInt32(scroll)) / 100;

            panelB.Refresh();
        }
Posted
Updated 16-Nov-20 6:54am
Comments
[no name] 16-Nov-20 12:25pm    
That's why you should use WPF when "zooming" is a requirement.

https://docs.microsoft.com/en-us/dotnet/api/system.windows.controls.viewbox?view=net-5.0

1 solution

I would use a splitContainer and a TableLayoutPanel.

In Panel1 of the splitcontainer: Dock your trackbar

In Panel2 of the splitcontainer: Dock a TableLayoutPanel (instead of panel B).

In each cell of the TableLayoutPanel dock one of the textboxes (dockStyle fillOut).

With the trackbar you can change the value of the splitcontainer's splitterdistance property => this enables you to zoom.

You could also change the size of the splitContainer.
 
Share this answer
 
Comments
BillWoodruff 17-Nov-20 3:39am    
interesting idea, however, changing splitterdistance is only going to change the size of the interior panels in one dimension, horizontal or vertical.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900