+ Reply to Thread
Results 1 to 3 of 3

Thread: adaptive user control

  1. #1
    anand.neeli is offline VB.NET Forum Newbie anand.neeli is on a distinguished programming path ahead
    .NET Framework
    .NET 3.5 (VS 2008)
    Join Date
    Jun 2009
    Posts
    4
    Reputation
    0

    Default adaptive user control

    Hi Experts,

    i have a user control which opens a file and renders data in some specific format.
    is there a way to make sure that each instance of user control operate on different file (which can be obtained from mail form)

    To tell shortly, how can user control be loaded with some paramaters/data from main form?

    Thanks in advance.

  2. #2
    newguy's Avatar
    newguy is offline VB.NET Forum Idol newguy puts e.f. hutton to shame newguy puts e.f. hutton to shame newguy puts e.f. hutton to shame newguy puts e.f. hutton to shame newguy puts e.f. hutton to shame newguy puts e.f. hutton to shame newguy puts e.f. hutton to shame
    .NET Framework
    .NET 3.5 (VS 2008)
    Join Date
    Jun 2008
    Location
    Denver Co, USA
    Posts
    609
    Reputation
    217

    Default

    Sure, make a Sub New with parameters in the UC's code:
    Code:
    Private m_FileName As String
    Public Sub New(ByVal fileName As String)
       InitializeComponent()
       m_FileName = filename
    End Sub
    Then when you create the UC it will look like this:
    Code:
    Dim uc As New UserControl1("C:\test.txt")
    Or you can just have the m_FileName set to Public and call it when creating it:
    Code:
    Dim uc As New UserControl1
    uc.m_FileName = "C:\test.txt"
    Last edited by newguy; 06-30-2009 at 3:17 PM.
    Close Counts for Horseshoes, Handgranades, and Nuclear Missiles!

  3. #3
    henryminute is offline VB.NET Forum Enthusiast henryminute is on a distinguished programming path ahead
    .NET Framework
    .NET 3.5 (VS 2008)
    Join Date
    Jul 2009
    Location
    UK
    Posts
    57
    Reputation
    17

    Default

    I don't want to seem picky, but.
    Fields should never be made public. The OP should create a Public Property for access to the m_Filename Field.
    Some create happiness wherever they go, others whenever - Oscar Wilde

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts