Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET General > Call a property of form dynamicly


Reply
 
Thread Tools Display Modes
  #1  
Old 08-03-2012, 08:25 AM
ohadw ohadw is offline
Newcomer
 
Join Date: Feb 2002
Posts: 22
Default Call a property of form dynamicly


Hi
I use VB.net 2010

I have a form with a datagrid. Everytime I call this form, I send a parameter of Datamember, and DataSource to ther datagrid, so I populate it with data.

I want to be able to do a double click on a cell on the datagrid, and it will call a form.

The new form has properties on it. Here is an example a form:
Code:
Public Class bgUnitsi
    Inherits bgCldFrm
    Implements AmiDorGL.glGFuncs.ICommandEnterQry
    Implements AmiDorGL.glGFuncs.ICommandExecQry
    Implements AmiDorGL.glGFuncs.ICommandNew
    Implements AmiDorGL.glGFuncs.ICommandSave
    Implements AmiDorGL.glGFuncs.ICommandDelete
    Private clsbgUnitsOra As New bgUnitsi_Ora
    Private clsbgUnitsSQL As New bgUnitsi_SQL

    Dim _iCatalogId As Integer
    Dim _stUnitId As String

    Public Property CatalogId() As Integer
        Get
            Return _iCatalogId
        End Get
        Set(ByVal Value As Integer)
            txtCatalogId.Text = Value
        End Set
    End Property

    Public Property UnitId() As String
        Get
            Return _stUnitId
        End Get
        Set(ByVal Value As String)
            stUnitId = Value
        End Set
    End Property
If I use a direct call to it, it works great. Here is an example:
Code:
objFrmName = GetFormByName("bgUnitsi")
                    objFrmName.CatalogId = dgResults(dgResults.CurrentCell.RowNumber, 12)
                    objFrmName.UnitId= dgResults(dgResults.CurrentCell.RowNumber, _
                    dgResults.CurrentCell.ColumnNumber)
                    DrillToChildClass(objFrmName)
I want to use a dynamic call for form property (so I can send the form name, property name and the values is should have in one place)
This is the code I used, but it not work:
This is the sub:
Code:
   Sub OpenChildForm(ByRef stChildForm As String, ByRef stParamString As String, _
                      ByRef iTotalParts As Integer)
        Dim fFrmName As New Object
        Dim stParamGeneral As String
        'Dim iIndex As Integer
        Dim stParamName(iTotalParts) As String
        Dim stParam(iTotalParts) As String
        Try
            fFrmName = LocalGetFormByName(stChildForm)
            For iPart As Integer = 1 To iTotalParts
                stParamGeneral = AmiDorGL.glGFuncs.SplitString(stParamString, "|", _
                iTotalParts, iPart)
                'iIndex = AmiDorGL.glGFuncs.SplitString(stParamGeneral, "#", 2, 1)
                stParamName(iPart) = AmiDorGL.glGFuncs.SplitString(stParamGeneral, "#", 2, 1)
                stParam(iPart) = AmiDorGL.glGFuncs.SplitString(stParamGeneral, "#", 2, 2)
                fFrmName.stParamName(iPart) = stParam(iPart)
            Next
            'Parameters
            DrillToChildClass(fFrmName)
        Catch ex As Exception
            HandleExceptions(ex)
        End Try
    End Sub
and this is the call to the sub:
Code:
bgQuryVw.OpenChildForm("bgUnitsi", "CatalogId#1|UnitId#1", 2)
If I ceck on debug mode, I see that the parameters stParamName(iPart) and stParam(iTotalParts) get the correct values. The error rise on the next statement : fFrmName.stParamName(iPart) = stParam(iPart) and say "Public member 'stParamName' on type 'bgUnitsi' not found."

What I do wrong?

Thanks
Reply With Quote
  #2  
Old 08-07-2012, 09:54 AM
ohadw ohadw is offline
Newcomer
 
Join Date: Feb 2002
Posts: 22
Unhappy Any idea

Anyone has any idea?
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->