|
-
Feb 26th, 2015, 11:24 AM
#1
Thread Starter
Hyperactive Member
User Controls
Hi
I am trying to move my code to user controls so its easier to reuse the code.
I have created a control which has a dateTo and dateFrom and a submit button. The results I thought should be populated into another user control which contains a gridview.
How do I set the gridview datasource if it is in another UC?
Thank u in advance....
-
Feb 26th, 2015, 11:43 AM
#2
Re: User Controls
To pass the data from UC1 to UC2 directly, UC1 need to have a reference to UC2. This is not typically the case though. I would look at passing the data through an event raised in UC1 and handled in UC2.
kevin
Edit,
Something like this
VB Code:
Public Class Form1 Dim c1 As New UC1Class Dim c2 As New UC2Class Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load AddHandler c1.gotData, AddressOf c2.getData End Sub End Class Public Class UC1Class Public Event gotData(data As Object) Private Sub RaiseDataEvent() RaiseEvent gotData(New Object) End Sub End Class Public Class UC2Class Public Sub getData(data As Object) 'do what you will with the data End Sub End Class
Last edited by kebo; Feb 26th, 2015 at 01:03 PM.
Process control doesn't give you good quality, it gives you consistent quality.
Good quality comes from consistently doing the right things.
Vague general questions have vague general answers. A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.
______________________________ Last edited by kebo : Now. Reason: superfluous typo's
Tags for this Thread
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
|