|
Nicely Done. However it makes my fonts smaller than originally specified and moves alignment. Could this be due to Autosizemode being set to dpi rather than font?
|
|
|
|
|
It work for me
Thank you so much
|
|
|
|
|
Excellent class for resizing the control.
I have a small issue, i am having a line and rectangle shape control in my form and these two are not getting resized.
Please guide me how to solve it.
Thanks in advance.
|
|
|
|
|
Hi Member 10974085
Two things to you.
1. The resizer class work ok for
me except the buttons are
Somewhat distorted.
2. I want to do a small change
and for that I need your help.
I want to keep height/width
Of original form ratio to be fix
Manly after form dragging
The form height staying as is
And the width will be changed
So to keep the fix ratio.
Thank you in advanced
This is my form
<global.microsoft.visualbasic.compilerservices.designergenerated()> _
Partial Class ehRegExForm
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<system.diagnostics.debuggernonusercode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<system.diagnostics.debuggerstepthrough()> _
Private Sub InitializeComponent()
Me.RETextBox = New System.Windows.Forms.TextBox()
Me.ReplaceSplitTextBox = New System.Windows.Forms.TextBox()
Me.InputTextBox = New System.Windows.Forms.TextBox()
Me.RELabel = New System.Windows.Forms.Label()
Me.ReplceSplitLabel = New System.Windows.Forms.Label()
Me.InputLabel = New System.Windows.Forms.Label()
Me.OutputLabel = New System.Windows.Forms.Label()
Me.OutputTextBox = New System.Windows.Forms.TextBox()
Me.ShowReTextBox = New System.Windows.Forms.TextBox()
Me.MatchButton = New System.Windows.Forms.Button()
Me.ReplaceButton = New System.Windows.Forms.Button()
Me.SplitButton = New System.Windows.Forms.Button()
Me.ClearButton = New System.Windows.Forms.Button()
Me.CloseButton = New System.Windows.Forms.Button()
Me.IgnoreCaseCheckBox = New System.Windows.Forms.CheckBox()
Me.SingleLineCheckBox = New System.Windows.Forms.CheckBox()
Me.MultilineCheckBox = New System.Windows.Forms.CheckBox()
Me.ExplicitCaptureCheckBox = New System.Windows.Forms.CheckBox()
Me.RightToLeftCheckBox = New System.Windows.Forms.CheckBox()
Me.OpenAllButton = New System.Windows.Forms.Button()
Me.SaveAllButton = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'RETextBox
'
Me.RETextBox.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.RETextBox.Location = New System.Drawing.Point(23, 90)
Me.RETextBox.Multiline = True
Me.RETextBox.Name = "RETextBox"
Me.RETextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both
Me.RETextBox.Size = New System.Drawing.Size(520, 250)
Me.RETextBox.TabIndex = 0
Me.RETextBox.WordWrap = False
'
'ReplaceSplitTextBox
'
Me.ReplaceSplitTextBox.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ReplaceSplitTextBox.Location = New System.Drawing.Point(603, 90)
Me.ReplaceSplitTextBox.Multiline = True
Me.ReplaceSplitTextBox.Name = "ReplaceSplitTextBox"
Me.ReplaceSplitTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both
Me.ReplaceSplitTextBox.Size = New System.Drawing.Size(520, 250)
Me.ReplaceSplitTextBox.TabIndex = 1
Me.ReplaceSplitTextBox.WordWrap = False
'
'InputTextBox
'
Me.InputTextBox.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.InputTextBox.Location = New System.Drawing.Point(23, 390)
Me.InputTextBox.Multiline = True
Me.InputTextBox.Name = "InputTextBox"
Me.InputTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both
Me.InputTextBox.Size = New System.Drawing.Size(1100, 250)
Me.InputTextBox.TabIndex = 2
Me.InputTextBox.WordWrap = False
'
'RELabel
'
'Me.RELabel.AutoSize = False
Me.RELabel.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.RELabel.Location = New System.Drawing.Point(154, 59)
Me.RELabel.Name = "RELabel"
Me.RELabel.Size = New System.Drawing.Size(258, 25)
Me.RELabel.TabIndex = 4
Me.RELabel.Text = "Regular Expressions Pattern"
Me.RELabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'ReplceSplitLabel
'
'Me.ReplceSplitLabel.AutoSize = False
Me.ReplceSplitLabel.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ReplceSplitLabel.Location = New System.Drawing.Point(772, 59)
Me.ReplceSplitLabel.Name = "ReplceSplitLabel"
Me.ReplceSplitLabel.Size = New System.Drawing.Size(182, 25)
Me.ReplceSplitLabel.TabIndex = 5
Me.ReplceSplitLabel.Text = "Replacement String"
Me.ReplceSplitLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'InputLabel
'
'Me.InputLabel.AutoSize = False
Me.InputLabel.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.InputLabel.Location = New System.Drawing.Point(524, 353)
Me.InputLabel.Name = "InputLabel"
Me.InputLabel.Size = New System.Drawing.Size(99, 25)
Me.InputLabel.TabIndex = 6
Me.InputLabel.Text = "Input Text"
Me.InputLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'OutputLabel
'
'Me.OutputLabel.AutoSize = False
Me.OutputLabel.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.OutputLabel.ForeColor = System.Drawing.Color.Green
Me.OutputLabel.Location = New System.Drawing.Point(516, 653)
Me.OutputLabel.Name = "OutputLabel"
Me.OutputLabel.Size = New System.Drawing.Size(115, 25)
Me.OutputLabel.TabIndex = 9
Me.OutputLabel.Text = "Output Text"
Me.OutputLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'OutputTextBox
'
Me.OutputTextBox.BackColor = System.Drawing.Color.White
Me.OutputTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None
Me.OutputTextBox.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.OutputTextBox.ForeColor = System.Drawing.Color.Green
Me.OutputTextBox.Location = New System.Drawing.Point(23, 691)
Me.OutputTextBox.Multiline = True
Me.OutputTextBox.Name = "OutputTextBox"
Me.OutputTextBox.ReadOnly = True
Me.OutputTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both
Me.OutputTextBox.Size = New System.Drawing.Size(1100, 250)
Me.OutputTextBox.TabIndex = 8
Me.OutputTextBox.WordWrap = False
'
'ShowReTextBox
'
Me.ShowReTextBox.BackColor = System.Drawing.Color.White
Me.ShowReTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None
Me.ShowReTextBox.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ShowReTextBox.ForeColor = System.Drawing.Color.Blue
Me.ShowReTextBox.Location = New System.Drawing.Point(23, 12)
Me.ShowReTextBox.Name = "ShowReTextBox"
Me.ShowReTextBox.ReadOnly = True
Me.ShowReTextBox.Size = New System.Drawing.Size(1254, 23)
Me.ShowReTextBox.TabIndex = 12
'
'MatchButton
'
Me.MatchButton.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.MatchButton.Location = New System.Drawing.Point(1138, 90)
Me.MatchButton.Name = "MatchButton"
Me.MatchButton.Size = New System.Drawing.Size(131, 35)
Me.MatchButton.TabIndex = 13
Me.MatchButton.Text = "Matches"
Me.MatchButton.UseVisualStyleBackColor = True
'
'ReplaceButton
'
Me.ReplaceButton.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ReplaceButton.Location = New System.Drawing.Point(1138, 141)
Me.ReplaceButton.Name = "ReplaceButton"
Me.ReplaceButton.Size = New System.Drawing.Size(131, 35)
Me.ReplaceButton.TabIndex = 14
Me.ReplaceButton.Text = "Replace"
Me.ReplaceButton.UseVisualStyleBackColor = True
'
'SplitButton
'
Me.SplitButton.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.SplitButton.Location = New System.Drawing.Point(1138, 192)
Me.SplitButton.Name = "SplitButton"
Me.SplitButton.Size = New System.Drawing.Size(131, 35)
Me.SplitButton.TabIndex = 15
Me.SplitButton.Text = "Split"
Me.SplitButton.UseVisualStyleBackColor = True
'
'ClearButton
'
Me.ClearButton.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ClearButton.Location = New System.Drawing.Point(1138, 244)
Me.ClearButton.Name = "ClearButton"
Me.ClearButton.Size = New System.Drawing.Size(131, 35)
Me.ClearButton.TabIndex = 16
Me.ClearButton.Text = "Clear"
Me.ClearButton.UseVisualStyleBackColor = True
'
'CloseButton
'
Me.CloseButton.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.CloseButton.Location = New System.Drawing.Point(1138, 886)
Me.CloseButton.Name = "CloseButton"
Me.CloseButton.Size = New System.Drawing.Size(130, 35)
Me.CloseButton.TabIndex = 17
Me.CloseButton.Text = "Close"
Me.CloseButton.UseVisualStyleBackColor = True
'
'IgnoreCaseCheckBox
'
'Me.IgnoreCaseCheckBox.AutoSize = True
Me.IgnoreCaseCheckBox.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.IgnoreCaseCheckBox.Location = New System.Drawing.Point(1138, 329)
Me.IgnoreCaseCheckBox.Name = "IgnoreCaseCheckBox"
Me.IgnoreCaseCheckBox.Size = New System.Drawing.Size(141, 29)
Me.IgnoreCaseCheckBox.TabIndex = 18
Me.IgnoreCaseCheckBox.Text = "Ignore Case"
Me.IgnoreCaseCheckBox.UseVisualStyleBackColor = True
'
'SingleLineCheckBox
'
'Me.SingleLineCheckBox.AutoSize = True
Me.SingleLineCheckBox.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.SingleLineCheckBox.Location = New System.Drawing.Point(1138, 399)
Me.SingleLineCheckBox.Name = "SingleLineCheckBox"
Me.SingleLineCheckBox.Size = New System.Drawing.Size(115, 29)
Me.SingleLineCheckBox.TabIndex = 19
Me.SingleLineCheckBox.Text = "SigleLine"
Me.SingleLineCheckBox.UseVisualStyleBackColor = True
'
'MultilineCheckBox
'
'Me.MultilineCheckBox.AutoSize = True
Me.MultilineCheckBox.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.MultilineCheckBox.Location = New System.Drawing.Point(1138, 364)
Me.MultilineCheckBox.Name = "MultilineCheckBox"
Me.MultilineCheckBox.Size = New System.Drawing.Size(112, 29)
Me.MultilineCheckBox.TabIndex = 20
Me.MultilineCheckBox.Text = "MultiLine"
Me.MultilineCheckBox.UseVisualStyleBackColor = True
'
'ExplicitCaptureCheckBox
'
'Me.ExplicitCaptureCheckBox.AutoSize = True
Me.ExplicitCaptureCheckBox.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ExplicitCaptureCheckBox.Location = New System.Drawing.Point(1138, 434)
Me.ExplicitCaptureCheckBox.Name = "ExplicitCaptureCheckBox"
Me.ExplicitCaptureCheckBox.Size = New System.Drawing.Size(104, 54)
Me.ExplicitCaptureCheckBox.TabIndex = 21
Me.ExplicitCaptureCheckBox.Text = "Explicit" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "Capture"
Me.ExplicitCaptureCheckBox.UseVisualStyleBackColor = True
'
'RightToLeftCheckBox
'
'Me.RightToLeftCheckBox.AutoSize = True
Me.RightToLeftCheckBox.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.RightToLeftCheckBox.Location = New System.Drawing.Point(1138, 493)
Me.RightToLeftCheckBox.Name = "RightToLeftCheckBox"
Me.RightToLeftCheckBox.Size = New System.Drawing.Size(134, 29)
Me.RightToLeftCheckBox.TabIndex = 23
Me.RightToLeftCheckBox.Text = "RightToLeft"
Me.RightToLeftCheckBox.UseVisualStyleBackColor = True
'
'OpenAllButton
'
Me.OpenAllButton.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.OpenAllButton.Location = New System.Drawing.Point(1138, 548)
Me.OpenAllButton.Name = "OpenAllButton"
Me.OpenAllButton.Size = New System.Drawing.Size(131, 39)
Me.OpenAllButton.TabIndex = 25
Me.OpenAllButton.Text = "Open"
Me.OpenAllButton.UseVisualStyleBackColor = True
'
'SaveAllButton
'
Me.SaveAllButton.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.SaveAllButton.Location = New System.Drawing.Point(1138, 601)
Me.SaveAllButton.Name = "SaveAllButton"
Me.SaveAllButton.Size = New System.Drawing.Size(131, 39)
Me.SaveAllButton.TabIndex = 26
Me.SaveAllButton.Text = "Save"
Me.SaveAllButton.UseVisualStyleBackColor = True
'
'ehRegExForm
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 16.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.AutoScroll = True
'Me.AutoSize = True
Me.ClientSize = New System.Drawing.Size(1302, 953)
Me.Controls.Add(Me.SaveAllButton)
Me.Controls.Add(Me.OpenAllButton)
Me.Controls.Add(Me.RightToLeftCheckBox)
Me.Controls.Add(Me.ExplicitCaptureCheckBox)
Me.Controls.Add(Me.MultilineCheckBox)
Me.Controls.Add(Me.SingleLineCheckBox)
Me.Controls.Add(Me.IgnoreCaseCheckBox)
Me.Controls.Add(Me.CloseButton)
Me.Controls.Add(Me.ClearButton)
Me.Controls.Add(Me.SplitButton)
Me.Controls.Add(Me.ReplaceButton)
Me.Controls.Add(Me.MatchButton)
Me.Controls.Add(Me.ShowReTextBox)
Me.Controls.Add(Me.OutputLabel)
Me.Controls.Add(Me.OutputTextBox)
Me.Controls.Add(Me.InputLabel)
Me.Controls.Add(Me.ReplceSplitLabel)
Me.Controls.Add(Me.RELabel)
Me.Controls.Add(Me.InputTextBox)
Me.Controls.Add(Me.ReplaceSplitTextBox)
Me.Controls.Add(Me.RETextBox)
Me.HelpButton = True
'Me.MaximumSize = New System.Drawing.Size(1320, 1000)
'Me.MinimumSize = New System.Drawing.Size(1320, 1000)
Me.Name = "ehRegExForm"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "ehRegExTester : Programed by Haviv Elbaz Sep 2019"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents RETextBox As System.Windows.Forms.TextBox
Friend WithEvents ReplaceSplitTextBox As System.Windows.Forms.TextBox
Friend WithEvents InputTextBox As System.Windows.Forms.TextBox
Friend WithEvents RELabel As System.Windows.Forms.Label
Friend WithEvents ReplceSplitLabel As System.Windows.Forms.Label
Friend WithEvents InputLabel As System.Windows.Forms.Label
Friend WithEvents OutputLabel As System.Windows.Forms.Label
Friend WithEvents OutputTextBox As System.Windows.Forms.TextBox
Friend WithEvents ShowReTextBox As System.Windows.Forms.TextBox
Friend WithEvents MatchButton As System.Windows.Forms.Button
Friend WithEvents ReplaceButton As System.Windows.Forms.Button
Friend WithEvents SplitButton As System.Windows.Forms.Button
Friend WithEvents ClearButton As System.Windows.Forms.Button
Friend WithEvents CloseButton As System.Windows.Forms.Button
Friend WithEvents IgnoreCaseCheckBox As System.Windows.Forms.CheckBox
Friend WithEvents SingleLineCheckBox As System.Windows.Forms.CheckBox
Friend WithEvents MultilineCheckBox As System.Windows.Forms.CheckBox
Friend WithEvents ExplicitCaptureCheckBox As System.Windows.Forms.CheckBox
Friend WithEvents RightToLeftCheckBox As System.Windows.Forms.CheckBox
Friend WithEvents OpenAllButton As System.Windows.Forms.Button
Friend WithEvents SaveAllButton As System.Windows.Forms.Button
End Class
What I need to change so the resize
Be smooth.
Because the font don't proportional.
Thank you agay.
modified 21-Oct-19 23:39pm.
|
|
|
|
|
|
it was very useful to me, many thanks
|
|
|
|
|
Thanks For The Code It works like Charma
|
|
|
|
|
Brilliant solution. Excellent coding and code documentation. I copied and pasted the code and it worked perfectly.
|
|
|
|
|
Public Class BaseForm
Public rs As New FormResizer
Private Sub Form1_Resize(sender As Object, e As EventArgs) Handles Me.Resize
rs.ResizeAllControls(Me, Me.Width, Me.Height)
End Sub
'Sub New()
' rs.FindAllControls(Me)
'End Sub
Public Class FormResizer
Private Structure ControlInfo
Public name As String
Public left As Integer
Public top As Integer
Public originalHeight As Integer
Public originalWidth As Integer
Public originalFontSize As Single
End Structure
Public originalHeight As Integer = -1
Public originalWidth As Integer = -1
Private ctrlDict As Dictionary(Of String, ControlInfo) = New Dictionary(Of String, ControlInfo)
Public Sub FindAllControls(thisCtrl As Control)
If originalHeight = -1 Then
originalHeight = thisCtrl.Height
End If
If originalWidth = -1 Then
originalWidth = thisCtrl.Width
End If
For Each ctl As Control In thisCtrl.Controls
Try
Dim c As New ControlInfo
c.name = ctl.Name
c.top = ctl.Top
c.left = ctl.Left
c.originalFontSize = ctl.Font.Size
c.originalHeight = ctl.Height
c.originalWidth = ctl.Width
ctrlDict.Add(c.name, c)
Catch ex As Exception
Debug.Print(ex.Message)
MsgBox(ex.Message)
End Try
If ctl.Controls.Count > 0 Then
FindAllControls(ctl)
End If
Next
End Sub
Public Sub ResizeAllControls(thisCtrl As Control, FormWidth As Integer, FormHeight As Integer)
If originalHeight = -1 Or originalWidth = -1 Then
Exit Sub
End If
Dim currentHeightFactor As Double = FormHeight / originalHeight
Dim currentWidthFactor As Double = FormWidth / originalWidth
For Each ctl As Control In thisCtrl.Controls
Try
Dim c As New ControlInfo
Dim ret As Boolean = False
Try
ret = ctrlDict.TryGetValue(ctl.Name, c)
If (ret) Then
'-- Position
ctl.Top = Int(c.top * currentHeightFactor)
ctl.Left = Int(c.left * currentWidthFactor)
ctl.Width = Int(c.originalWidth * currentWidthFactor)
ctl.Height = Int(c.originalHeight * currentHeightFactor)
'-- Font
Dim f As Font = ctl.Font
Dim fratio As Single = (currentHeightFactor + currentWidthFactor) / 2
ctl.Font = New Font(f.FontFamily, c.originalFontSize * fratio, f.Style)
End If
Catch
End Try
Catch ex As Exception
End Try
If ctl.Controls.Count > 0 Then
ResizeAllControls(ctl, FormWidth, FormHeight)
End If
Next
End Sub
End Class
End Class
|
|
|
|
|
|
Thank You for sharing this version.
A small unsharpness happens. At runtime I received the unfriendly message: "An item of same key has already been added".
After some investigation I've found the point that produced this error.
I modified the code in Your class inside the FindAllControls subroutine as following:
If Not ctrlDict.ContainsKey(c.name) Then
ctrlDict.Add(c.name, c)
End If
I hope there are no side effects now
|
|
|
|
|
Instead of calling FindAllControls() inside MyBase.Load >> Try to do it on the Form Initialization
Sub New()
rs.FindAllControls(Panel1)
End Sub
Otherwise, works great!
THANKS!
|
|
|
|
|
Working Great,,,Nice Tut sir,,,
|
|
|
|
|
|
worked great but two problems
slow when changing sizes|
the text and some component became bigger and didn`t maintain good position
|
|
|
|
|
Thank you for sharing - this is a most elegant solution for something that I have pondered for some time.
I have used the code on my project and the only control that does not resize is the DataGridView control. Are you able to suggest a fix for this control ?
|
|
|
|
|
You could put the DataGridView in a Container, dock it and set:
.Dock.Fill +
.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells
.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells
An for all the Columns set Autosizemode to Fill + MOdify the FillWeight Property of each Column to specify the actual width during rezising
This worked pretty well for me
|
|
|
|
|
|
is there a way to exclude one control from resizing using a custom class for a imageviewer and it comes with its on auto resizing. so is there a way for me to exclude just that?
should add the control does not have a auto resize option
|
|
|
|
|
In form's maximize mode, the font of combo-box items get correctly its dimensions (larger font). But, in minimize mode, the font remain large (not reduced).
The problem is solved by adding:
If (ctl.GetType() Is GetType(ComboBox)) Then
' Skip ComboBox
Else
ctl.Font = New Font(f.FontFamily, c.originalFontSize * fontRatio, f.Style)
End If
In ResizeAllControls Sub
Anyway, thank you very much for this great code, it saves me a lot of time in resizing each controls on form manually.
modified 15-Nov-16 20:04pm.
|
|
|
|
|
In Load, I got message; NullReference. Additional information: Object reference not set to an instance of an object. Please help.
|
|
|
|
|
Thanks a lot for this greate code example it saved me a lot of work.
It works great except by one control element an thats is with NumericUpDown objects.
Its resizes it corrent but it sets the fontsize wrong so only a part of the numbers is viewable afterwords.
But else a greate job.
Thanks.
|
|
|
|
|
Thanks Centauri_dk. I did not use the code with the NumericUpDown control. Good catch. We would need to skip the font resizing for that control type.
|
|
|
|
|
Hi, as subject
if I've a button with an image how can I resize also the image ?
thank you in advance
nicola
|
|
|
|
|
Excellent updates to improve speed appearance davepank and 11584228. Thanks. Community support = better code for us all.
|
|
|
|
|