|
-
Jul 20th, 2010, 04:11 AM
#10
Thread Starter
Addicted Member
Re: Checkboxs and OPtion buttons Dynamically
Thank u Veena Thank u so much....
It is Working.
In the above code i added two optionbuttons extra and i run the program it`s working.. But now my task is when i check the checkbox corresponding optionbutton should be Enabled otherwise it is Disabled.
and i am sending code which i was developed both Class and Form as below.
Class:
Option Explicit
Private WithEvents chkBox As CheckBox
Public Property Set Check_Box(Check_Box As CheckBox)
Set chkBox = Check_Box
End Property
Private Sub chkBox_GotFocus()
chkBox.BackColor = vbBlue
End Sub
Private Sub chkBox_LostFocus()
chkBox.BackColor = vbWhite
End Sub
Form:
Option Explicit
Dim i As Integer
Dim MyChkColl As Collection
Dim ctl As CheckBox
Dim Opt1 As OptionButton
Dim Opt2 As OptionButton
Private Sub Form_Load()
For i = 1 To 5
Me.Controls.Add "vb.Frame", "Frame1" & i
Me.Controls("Frame1" & i).Visible = True
Me.Controls("Frame1" & i).Top = 1400 * (i) + 400
Me.Controls("Frame1" & i).Width = 5000
Me.Controls("Frame1" & i).Height = 1400
Me.Controls("Frame1" & i).Left = 10000
'
Set MyChkColl = New Collection
'
Me.Controls.Add "vb.CheckBox", "Checkbox" & i
Set ctl = Me.Controls("Checkbox" & i)
Set ctl.Container = Me.Controls("Frame1" & i)
With ctl
.Visible = True
.Left = 100
.Top = 200
.Width = 4600
.Height = 400
End With
Me.Controls.Add "vb.OptionButton", "MyOptionbutton1" & i
Set Opt1 = Me.Controls("MyOptionbutton1" & i)
Set Opt1.Container = Me.Controls("Frame1" & i)
With Opt1
.Visible = True
.Top = 600
.Left = 100
.Width = 4600
.Height = 255
.Caption = "Current Year" & i
.Enabled = False
End With
Me.Controls.Add "vb.OptionButton", "MyOptionbutton2" & i
Set Opt2 = Me.Controls("MyOptionbutton2" & i)
Set Opt2.Container = Me.Controls("Frame1" & i)
With Opt2
.Visible = True
.Top = 900
.Left = 100
.Width = 4600
.Height = 195
.Caption = "Last Year" & i
.Enabled = False
End With
'
Dim tChk As New clsCheck
Set tChk.Check_Box = ctl
MyChkColl.Add tChk, ctl.Name
'
Next i
End Sub
So, now how can i write code for checkbox click event??
When i Click Checkbox(i) then OPtionbutton1(i) and OPtionbutton2(i) should Enable else Disable..
Thanks
Last edited by malatesh kumar; Jul 20th, 2010 at 04:14 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|