Results 1 to 2 of 2

Thread: User Controls

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2005
    Posts
    334

    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....

  2. #2
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    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:
    1. Public Class Form1
    2.  
    3.     Dim c1 As New UC1Class
    4.     Dim c2 As New UC2Class
    5.  
    6.     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    7.         AddHandler c1.gotData, AddressOf c2.getData
    8.  
    9.     End Sub
    10. End Class
    11.  
    12.  
    13. Public Class UC1Class
    14.     Public Event gotData(data As Object)
    15.     Private Sub RaiseDataEvent()
    16.         RaiseEvent gotData(New Object)
    17.     End Sub
    18. End Class
    19.  
    20. Public Class UC2Class
    21.     Public Sub getData(data As Object)
    22.  
    23.         'do what you will with the data
    24.  
    25.     End Sub
    26. 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
  •  



Click Here to Expand Forum to Full Width