Locked Combobox Width

  • 2 มีนาคม 2555 11:52
     
     

    Hi,

    I am trying to set the combo box width during run time. If I set combobox1.width=60 in the form_load it works perfect. But If I loop through all controls in the form using for each  statement, setting control.width for combobox fails and throws an error saying 'Parameter not Valid'. I have pasted the code below which is in a module. This routine is called in Form_load of every form.

    Note: I am using VB.net 2008 Professional, windows 7 and 64 bit.

    The same code works in another computer which has VB.net 2010 express edition, windows xp and 32 bit.

    Code in Module is below.

     Public Sub ControlSize(ByVal Controlname As Object, ByVal ControlTop As Integer, ByVal ControlLeft As Integer)
           
                Try
                    Control.width = Control.width * ML_scalefactor
                    Control.Height = Control.Height * ML_scalefactor

                    Control.top = Control.Top * ML_scalefactor
                    Control.left = Control.Left * ML_scalefactor
                    Debug.Print(Control.name & "," & Control.width & "," & Control.height & "," & Control.top & "," & Control.left)
                Catch ex As Exception
                    MsgBox(ex.Message)
                End Try
            Next

        End Sub

    Code in form_load  to call the above routine:

    Call ControlSize(Me, 200, 200)

    Many Thanks,

    • ย้ายโดย Terry WarwickMicrosoft 9 มีนาคม 2555 14:53 Wrong Forum (From:POS for .NET)
    •  

ตอบทั้งหมด

  • 1 เมษายน 2555 8:17
     
     

    Hi HariMani,

    try to call this event in Form Init Event.

    In which line did you get error message.

    Best Regards

    Anand

  • 13 เมษายน 2555 8:57
     
     

    Hello,

    Can you please tell us on which line do you get the error?