| | |
access events of form in UserControl
Thread Solved |
•
•
Join Date: Feb 2009
Posts: 4
Reputation:
Solved Threads: 0
access events of form in UserControl
i have
1)User control with one MSFlexGrid on it
2)Form to place user control
3)Some form's own control
i dont know how many controls are there under form
i have to place them in grid columns (eg. combobox in grid to provide its service)
now problem is if i place any control in grid after i LostFocus from that control i need to palce the value present in control in grid.
i cannot ask to write LostFocus function to my UserControl user or any programmer so i must have provision to catch events of controls available on form.
let's make question more simple
i need to access events of controls present on form in userControl without any code in form
i have
1)User control with one MSFlexGrid on it
2)Form to place user control
3)Some form's own control
i dont know how many controls are there under form
i have to place them in grid columns (eg. combobox in grid to provide its service)
now problem is if i place any control in grid after i LostFocus from that control i need to palce the value present in control in grid.
i cannot ask to write LostFocus function to my UserControl user or any programmer so i must have provision to catch events of controls available on form.
let's make question more simple
i need to access events of controls present on form in userControl without any code in form
Hi, U can use Usercontrol.Parent Property get the Parent object and use WithEvents keyword to capture the Parent events
Now your usercontrol receive the messages if its parent is form.
VB Syntax (Toggle Plain Text)
'In UserControl Option Explicit Dim WithEvents mParent As Form Private Sub mParent_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) MsgBox "Down" End Sub Public Sub SetParent(mParentForm As Form) Set mParent = mParentForm End Sub Private Sub UserControl_Show() If TypeOf UserControl.Parent Is Form Then Set mParent = UserControl.Parent End If End Sub
Now your usercontrol receive the messages if its parent is form.
KSG
![]() |
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: STOP a process in between .....
- Next Thread: How to : save an auto generated power point Slide to a folder and rename it
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





