Acessing forms dynamically

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KodeKrazy
    New Member
    • Mar 2008
    • 32

    Acessing forms dynamically

    Not sure exactly what I should be asking other than is there a way to get the code below (with modifications) to work. What I want to be able to do is to pass the name of the Form and the name of the ComboBox control to the Sub and have it add the "default" text at the top of the DD List based on which tool the user is currently using. Subsequently it will add the rest of the values from the database to the list.

    Any help or suggestions are appreciated.

    Thanks,

    KK

    Code:
            Public Sub fillCatalogCombo(ByVal frmName As Form, ByVal cbobxName As String)
    
            Dim CatCboFill As New linqFillCatalogCboDataContext
            Dim topText As String = ""
            Dim frmText As String = frmName.Name.ToString
            Select Case frmText
                Case "frmSearchItems"
                    topText = "All Catalogs"
                Case "frmItemMaintenance"
                    topText = "Enter or Select"
            End Select
    
            frmName.cbobxName.Items.Add(topText)
    
            Dim Cats = From c In CatCboFill.sp_FillItemSearchCatalogCbo Select c
            For Each Cat In Cats
                frmName.cbobxName.Items.Add(Cat.Description.ToString)
            Next
            CatCboFill = Nothing
    
        End Sub
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    If you have a public instance of the form (note, creating another isntance does NOT work) you can manipulate them directly.

    Comment

    Working...