Micro Focus QTP (UFT) Forums
Issues creating DotNetFactory Radio button using Loop - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Others (https://www.learnqtp.com/forums/Forum-UFT-QTP-Others)
+--- Thread: Issues creating DotNetFactory Radio button using Loop (/Thread-Issues-creating-DotNetFactory-Radio-button-using-Loop)



Issues creating DotNetFactory Radio button using Loop - kalpmist - 06-15-2015

Hi
I am trying to create a windows form with lots of radio buttons using a For loop (Successful). Later i need to check the value of the (Checked) Property for each radio button object...How can this be done? Below is the code.....

Code:
'Array for the text attachment.
Script = Array("","Script1","Script2","Script3","checkme","Script4")

'Creating Object for Form
Set objForm=DotNetFactory.CreateInstance("System.Windows.Forms.Form","System.Windows.Forms")
Set objBtn2=DotNetFactory.CreateInstance("System.Windows.Forms.Button", "System.Windows.Forms")
'#################################################################################################################################
'This will provide the locations(X,Y) for the controls
x=10
y=20
'############################################################################################################
'Setting the object drawing point
Set p1=DotNetFactory.CreateInstance("System.Drawing.Point","System.Drawing",x,y)
objForm.Height=1000
objForm.width=1000
'############################################################################################################
'Button with OK as text
objBtn2.Text= "OK"
p1.X=10
p1.Y= 10'60 '200
objBtn2.Location=p1
objForm.CancelButton=objBtn2
'############################################################################################################
'Constant values at the start of the FOR Loop
XValue = 10
YValue = 40
YIncrease = 20
'############################################################################################################
'For Loop
For i = 1 To UBOUND(Script)
    objRdi = objRd & i
    'validation for moving any script after no.25 to the next column
    If i = 25 Then
        MsgBox "check"
        XValue = 500
        YValue = 40
    ElseIf i < 25 Then
        XValue = 10
    End If
    'Creating Object for the radio button
    Set objRdi = DotNetFactory.CreateInstance("System.Windows.Forms.RadioButton", "System.Windows.Forms",
    'Setting properties for the radio button
    objRdi.Text=Script(i)
    objRdi.Name= "objRd" & i
    p1.X= XValue
    p1.Y= YValue
    objRdi.Location=p1
    objRdi.Width=400
    YValue = YValue + YIncrease
    objForm.Controls.Add(objRdi)
    If i = UBOUND(Script) Then
        objForm.Controls.Add(objBtn2)
        objForm.ShowDialog
    End If
Next
'Display based on the radio button



RE: Issues creating DotNetFactory Radio button using Loop - GSAT - 06-24-2015

I am looking for a similar crack buddy. Anyone out there?