zoom in and out the tabcontrol and its contents
-
hi all i am working on a project that uses a tab control having three tabs, now i need to add a zoom feature on the form that will allow the tab control to zoom in and zoom out with every control on it as well. if some one has any idea about it then please let me know. thanks in advance. help everyone
-
hi all i am working on a project that uses a tab control having three tabs, now i need to add a zoom feature on the form that will allow the tab control to zoom in and zoom out with every control on it as well. if some one has any idea about it then please let me know. thanks in advance. help everyone
One way to achieve Zoom effect with TabControl is to increase or decrease size of tab control and all of its pages including its contents according to the Zoom factor which is required. I tried to implement this functionality with a tab control and following code should give you the desired result- ---------------------Code Start-------------------------------------------------------- Code to ZoomIn- ----------------------------
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnZoomIn.Click Dim ZoomFactor As Integer = 25 'In percent For Each tbpg As TabPage In Me.TabControl1.TabPages For Each cntrl As Control In tbpg.Controls cntrl.Width += cntrl.Width * ZoomFactor / 100 cntrl.Height += cntrl.Height * ZoomFactor / 100 cntrl.Left += cntrl.Left * ZoomFactor / 100 cntrl.Top += cntrl.Top * ZoomFactor / 100 cntrl.Refresh() Next Next Me.TabControl1.Width += Me.TabControl1.Width * ZoomFactor / 100 Me.TabControl1.Height += Me.TabControl1.Height * ZoomFactor / 100 Me.TabControl1.Refresh() End Sub
--------------------------------- Code to ZoomOut – ---------------------------------Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnZoomOut.Click Dim ZoomFactor As Integer = 25 'In percent For Each tbpg As TabPage In Me.TabControl1.TabPages For Each cntrl As Control In tbpg.Controls cntrl.Width -= cntrl.Width * ZoomFactor / 100 cntrl.Height -= cntrl.Height * ZoomFactor / 100 cntrl.Left -= cntrl.Left * ZoomFactor / 100 cntrl.Top -= cntrl.Top * ZoomFactor / 100 cntrl.Refresh() Next Next Me.TabControl1.Width -= Me.TabControl1.Width * ZoomFactor / 100 Me.TabControl1.Height -= Me.TabControl1.Height * ZoomFactor / 100 Me.TabControl1.Refresh() End Sub
----------------------Code End--------------------- I hope this helps:). -Dave.Dave Traister, ComponentOne LLC. www.componentone.com
-
One way to achieve Zoom effect with TabControl is to increase or decrease size of tab control and all of its pages including its contents according to the Zoom factor which is required. I tried to implement this functionality with a tab control and following code should give you the desired result- ---------------------Code Start-------------------------------------------------------- Code to ZoomIn- ----------------------------
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnZoomIn.Click Dim ZoomFactor As Integer = 25 'In percent For Each tbpg As TabPage In Me.TabControl1.TabPages For Each cntrl As Control In tbpg.Controls cntrl.Width += cntrl.Width * ZoomFactor / 100 cntrl.Height += cntrl.Height * ZoomFactor / 100 cntrl.Left += cntrl.Left * ZoomFactor / 100 cntrl.Top += cntrl.Top * ZoomFactor / 100 cntrl.Refresh() Next Next Me.TabControl1.Width += Me.TabControl1.Width * ZoomFactor / 100 Me.TabControl1.Height += Me.TabControl1.Height * ZoomFactor / 100 Me.TabControl1.Refresh() End Sub
--------------------------------- Code to ZoomOut – ---------------------------------Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnZoomOut.Click Dim ZoomFactor As Integer = 25 'In percent For Each tbpg As TabPage In Me.TabControl1.TabPages For Each cntrl As Control In tbpg.Controls cntrl.Width -= cntrl.Width * ZoomFactor / 100 cntrl.Height -= cntrl.Height * ZoomFactor / 100 cntrl.Left -= cntrl.Left * ZoomFactor / 100 cntrl.Top -= cntrl.Top * ZoomFactor / 100 cntrl.Refresh() Next Next Me.TabControl1.Width -= Me.TabControl1.Width * ZoomFactor / 100 Me.TabControl1.Height -= Me.TabControl1.Height * ZoomFactor / 100 Me.TabControl1.Refresh() End Sub
----------------------Code End--------------------- I hope this helps:). -Dave.Dave Traister, ComponentOne LLC. www.componentone.com
thank you verry much for your kind help, but i need to enlarge the font size of each control and also control the anchoring of each control. i think the reason behind the unusual behavior of the tab control is that i set the location of the tab control on form's load event. let me tell you what i did i take a panel, place the tab control on that panel so that the panel become the parent of the tab control, now i set the auto scroll property of panel to true, set the dock property of panel to fill. this will zoom the tab control, the other control on each tab but the font size remains same. what else i can do to work it properly. i more thing i have one more tab control on the first tab page of the main tab control. the things goes complicated now with this second tab control. thanks in advance help everyone -- modified at 6:50 Wednesday 24th October, 2007
-
thank you verry much for your kind help, but i need to enlarge the font size of each control and also control the anchoring of each control. i think the reason behind the unusual behavior of the tab control is that i set the location of the tab control on form's load event. let me tell you what i did i take a panel, place the tab control on that panel so that the panel become the parent of the tab control, now i set the auto scroll property of panel to true, set the dock property of panel to fill. this will zoom the tab control, the other control on each tab but the font size remains same. what else i can do to work it properly. i more thing i have one more tab control on the first tab page of the main tab control. the things goes complicated now with this second tab control. thanks in advance help everyone -- modified at 6:50 Wednesday 24th October, 2007
Font can be resized using code like this- cntrl.Font = New Font(cntrl.Font.Name, cntrl.Font.Size + cntrl.Font.Size * ZoomFactor / 100, cntrl.Font.Style, GraphicsUnit.Pixel) -Dave.
Dave Traister, ComponentOne LLC. www.componentone.com