Click here to Skip to main content
15,902,635 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Make application's forms independent from Screen resolution Pin
Eddy Vluggen7-Feb-16 8:37
professionalEddy Vluggen7-Feb-16 8:37 
GeneralRe: Make application's forms independent from Screen resolution Pin
satc7-Feb-16 8:41
satc7-Feb-16 8:41 
GeneralRe: Make application's forms independent from Screen resolution Pin
Eddy Vluggen7-Feb-16 8:56
professionalEddy Vluggen7-Feb-16 8:56 
GeneralRe: Make application's forms independent from Screen resolution Pin
satc7-Feb-16 9:18
satc7-Feb-16 9:18 
GeneralRe: Make application's forms independent from Screen resolution Pin
Eddy Vluggen7-Feb-16 9:23
professionalEddy Vluggen7-Feb-16 9:23 
GeneralRe: Make application's forms independent from Screen resolution Pin
satc7-Feb-16 9:24
satc7-Feb-16 9:24 
GeneralRe: Make application's forms independent from Screen resolution Pin
Eddy Vluggen7-Feb-16 9:40
professionalEddy Vluggen7-Feb-16 9:40 
GeneralRe: Make application's forms independent from Screen resolution Pin
satc7-Feb-16 8:54
satc7-Feb-16 8:54 
And here is a class that I've found , but I think it needs some modifications :

VB.NET
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Windows.Forms
Imports System.Drawing
Imports System.ComponentModel

Public Class FormResizer

    'Considerations:
    'Change the Form AutoSize Mode to None.
    Private f_HeightRatio As New Single()
    Private f_WidthRatio As New Single()

    Public Sub ResizeForm(ByVal ObjForm As Form, ByVal DesignerWidth As Integer, ByVal DesignerHeight As Integer)
        '#Region "Code for Resizing and Font Change According to Resolution"
        'Specify Here the Resolution Y component in which this form is designed
        'For Example if the Form is Designed at 800 * 600 Resolution then DesignerHeight=600
        Dim i_StandardHeight As Integer = DesignerHeight

        'Specify Here the Resolution X component in which this form is designed
        'For Example if the Form is Designed at 800 * 600 Resolution then DesignerWidth=800
        Dim i_StandardWidth As Integer = DesignerWidth
        Dim i_PresentHeight As Integer = Screen.PrimaryScreen.Bounds.Height

        'Present Resolution Height
        Dim i_PresentWidth As Integer = Screen.PrimaryScreen.Bounds.Width

        'Presnet Resolution Width
        f_HeightRatio = CSng(CSng(i_PresentHeight) / CSng(i_StandardHeight))
        f_WidthRatio = CSng(CSng(i_PresentWidth) / CSng(i_StandardWidth))
        ObjForm.AutoScaleMode = AutoScaleMode.None

        'Make the Autoscale Mode=None
        ObjForm.Scale(New SizeF(f_WidthRatio, f_HeightRatio))
        For Each c As Control In ObjForm.Controls
            If c.HasChildren Then
                ResizeControlStore(c)
            Else
                c.Font = New Font(c.Font.FontFamily, c.Font.Size * f_HeightRatio, c.Font.Style, c.Font.Unit, CByte(0))
            End If
        Next
        ObjForm.Font = New Font(ObjForm.Font.FontFamily, ObjForm.Font.Size * f_HeightRatio, ObjForm.Font.Style, ObjForm.Font.Unit, CByte(0))
    End Sub

    ''' <summary>
    ''' This Function is Used to Change the Font of Controls that are Nested in Other Controls.
    ''' </summary>
    ''' <param name="objCtl"></param>
    Public Sub ResizeControlStore(ByVal objCtl As Control)
        If objCtl.HasChildren Then
            For Each cChildren As Control In objCtl.Controls
                If cChildren.HasChildren Then
                    ResizeControlStore(cChildren)
                Else
                    cChildren.Font = New Font(cChildren.Font.FontFamily, cChildren.Font.Size * f_HeightRatio, cChildren.Font.Style, cChildren.Font.Unit, CByte(0))
                End If
            Next
            objCtl.Font = New Font(objCtl.Font.FontFamily, objCtl.Font.Size * f_HeightRatio, objCtl.Font.Style, objCtl.Font.Unit, CByte(0))
        Else
            objCtl.Font = New Font(objCtl.Font.FontFamily, objCtl.Font.Size * f_HeightRatio, objCtl.Font.Style, objCtl.Font.Unit, CByte(0))
        End If
   End Sub
End Class

SuggestionRe: Make application's forms independent from Screen resolution Pin
Richard Deeming8-Feb-16 2:20
mveRichard Deeming8-Feb-16 2:20 
GeneralRe: Make application's forms independent from Screen resolution Pin
satc9-Feb-16 5:24
satc9-Feb-16 5:24 
QuestionDatagridview date sort - Tons of examples online, no answers Pin
Dan Chapin5-Feb-16 3:09
Dan Chapin5-Feb-16 3:09 
AnswerRe: Datagridview date sort - Tons of examples online, no answers Pin
Dave Kreskowiak5-Feb-16 4:09
mveDave Kreskowiak5-Feb-16 4:09 
AnswerRe: Datagridview date sort - Tons of examples online, no answers Pin
Richard Deeming5-Feb-16 4:24
mveRichard Deeming5-Feb-16 4:24 
QuestionHow to set textbox readonly from Selected value from Combobox Pin
Reginald_13-Feb-16 2:14
Reginald_13-Feb-16 2:14 
AnswerRe: How to set textbox readonly from Selected value from Combobox Pin
Dave Kreskowiak3-Feb-16 2:45
mveDave Kreskowiak3-Feb-16 2:45 
GeneralRe: How to set textbox readonly from Selected value from Combobox Pin
Reginald_19-Feb-16 7:54
Reginald_19-Feb-16 7:54 
GeneralRe: How to set textbox readonly from Selected value from Combobox Pin
Dave Kreskowiak9-Feb-16 8:31
mveDave Kreskowiak9-Feb-16 8:31 
AnswerRe: How to set textbox readonly from Selected value from Combobox Pin
ZurdoDev9-Feb-16 8:15
professionalZurdoDev9-Feb-16 8:15 
Questionvb Pin
Member 123040962-Feb-16 18:34
Member 123040962-Feb-16 18:34 
GeneralRe: vb Pin
PIEBALDconsult2-Feb-16 18:34
mvePIEBALDconsult2-Feb-16 18:34 
SuggestionRe: vb Pin
Richard MacCutchan2-Feb-16 22:11
mveRichard MacCutchan2-Feb-16 22:11 
GeneralRe: vb Pin
Sascha Lefèvre2-Feb-16 22:54
professionalSascha Lefèvre2-Feb-16 22:54 
QuestionRe: vb Pin
CHill604-Feb-16 4:01
mveCHill604-Feb-16 4:01 
GeneralRe: vb Pin
Sascha Lefèvre4-Feb-16 4:12
professionalSascha Lefèvre4-Feb-16 4:12 
AnswerRe: vb Pin
ZurdoDev9-Feb-16 8:16
professionalZurdoDev9-Feb-16 8:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.