Solved

User Controls and referencing them

Posted on 2006-07-18
2
164 Views
Last Modified: 2010-04-23
Hi there, I have a user control called Rate.  Rate is many text boxes, and I have a public function within rate called get_Rate which returns an integer relating to the values in all the text boxes.  i.e. if i know the rate_ID i know the values of all the boxes in the Rate control.

On any given form many instances of the control can be created programatically.

I am at a point in my code where i need to cycle through all the controls on a page, the user control and text boxes, combos etc.

    'Standard structure for recording an entry
    Public Structure TrackData
        Dim Ref As Integer
        Dim Data As String
    End Structure

    Public Sub Capture(ByRef pArray As ArrayList, ByRef pPanel As Panel)
        'Put all data into an array as a benchmark for checking against later.
        pArray.Clear() 'delete everything from current array
        Dim td As New TrackData
        Dim ctrl As Control
        For Each ctrl In pPanel.Controls
            If TypeOf ctrl Is TextBox Or TypeOf ctrl Is ComboBox Then
                td.Ref = ctrl.Handle
                td.Data = ctrl.Text
                pArray.Add(td)
            End If
            If TypeOf ctrl Is Rate Then
                td.Ref = ctrl.Handle
                td.Data = ctrl.get_Rate()
            End If
        Next
    End Sub

The piece of code errors on ctrl.get_Rate.  This is a public function however!

How do i get around this??

Many thanks, 500 points on offer!
0
Comment
Question by:DavidGreenfield
2 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 500 total points
ID: 17128551
Hi DavidGreenfield,

td.Data = Ctype(ctrl,Rate).get_Rate()

Perhaps

Tim Cottee
0
 

Author Comment

by:DavidGreenfield
ID: 17128635
Yes that works!  I hadn't realised you could do that for a user control!

Many thanks, 500 points on the way!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This video discusses moving either the default database or any database to a new volume.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now