Visualizzazione dei risultati da 1 a 2 su 2

Discussione: Controlli Runtime

  1. #1
    Utente di HTML.it
    Registrato dal
    Sep 2005
    Messaggi
    99

    Controlli Runtime

    ciao a tutti che mi potete dare una mano

    allora io ho creato un classe chiamata
    ControlliState
    codice:
       Private lHeight As Long
        Private lTop As Long
        Private lLeft As Long
        Private lWidth As Long
        Private lType As CtrlType
    
    
    Public Enum CtrlType
            Button = 1
            Label = 2
            Texbox = 3
            Listbox = 4
        End Enum
    
    
     Public Sub New()
            Select Case lType
                Case CtrlType.Button
    
                    lHeight = K_INVALID_VALUE
                    lTop = K_INVALID_VALUE
                    lLeft = K_INVALID_VALUE
                    lWidth = K_INVALID_VALUE
                    lType = 1
    
                Case CtrlType.Label
    
                    lHeight = K_INVALID_VALUE
                    lTop = K_INVALID_VALUE
                    lLeft = K_INVALID_VALUE
                    lWidth = K_INVALID_VALUE
                    lType = 2
    
                Case CtrlType.Listbox
    
                    lHeight = K_INVALID_VALUE
                    lTop = K_INVALID_VALUE
                    lLeft = K_INVALID_VALUE
                    lWidth = K_INVALID_VALUE
                    lType = 3
    
                Case CtrlType.Texbox
    
                    lHeight = K_INVALID_VALUE
                    lTop = K_INVALID_VALUE
                    lLeft = K_INVALID_VALUE
                    lWidth = K_INVALID_VALUE
                    lType = 4
    
            End Select
    
        End Sub
    
     Property Width() As Long
            Get
                Width = lWidth
            End Get
            Set(ByVal lValue As Long)
                If (lValue < K_INVALID_VALUE) Then
                    lValue = K_INVALID_VALUE
                End If
                lWidth = lValue
            End Set
        End Property
    
       Property Height() As Long
            Get
                Height = lHeight
            End Get
            Set(ByVal lValue As Long)
                If lValue < K_INVALID_VALUE Then
                    lValue = K_INVALID_VALUE
                End If
                lHeight = lValue
            End Set
        End Property
        Property Top() As Long
            Get
                Top = lTop
            End Get
            Set(ByVal lValue As Long)
                If lValue < K_INVALID_VALUE Then
                    lValue = K_INVALID_VALUE
                End If
                lTop = lValue
            End Set
        End Property
        Property Left() As Long
            Get
                Left = lLeft
            End Get
            Set(ByVal lValue As Long)
                If (lValue < K_INVALID_VALUE) Then
                    lValue = K_INVALID_VALUE
                End If
                lLeft = lValue
            End Set
        End Property
    e fin ok poi ho un altra classe chiamata Prospetti
    codice:
    
     Public Sub Initialize()
            Dim oElement As ClControlState
              oElement = New ClControlState
            oElement.Height = 50
            oElement.Width = 100
            oElement.Left = 100
            oElement.Top = 60
            oElement.Type = 1
      
        End Sub
    ora nn riesco a capire come ..generare la mia pagina aspx
    con il mio bottone in questo caso visto che il Type = 1...
    nn riesco a capire... dovrei convertire il tutto in Webcontorl??
    mi aiutate??
    Thk

  2. #2
    Utente di HTML.it
    Registrato dal
    Sep 2005
    Messaggi
    99
    Dopo un bel po ho capito come fare però mi da un errore :

    Object reference not set to an instance of an object.
    me lo fa su oState e a se nn metto new ..uffi aiuto

    questo è il codice..come mai secondo voi??
    codice:
    Code:
    
    Imports WebCartella.ClProspetto 
    Imports WebCartella.ClControlState 
    Imports WebCartella.Dichiarazioni 
    
    
    
    Public Class Template 
        Inherits System.Web.UI.Page 
    
    #Region " Web Form Designer Generated Code " 
    
        'This call is required by the Web Form Designer. 
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() 
    
        End Sub 
    
        'NOTE: The following placeholder declaration is required by the Web Form Designer. 
        'Do not delete or move it. 
        Private designerPlaceholderDeclaration As System.Object 
    
        Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 
            'CODEGEN: This method call is required by the Web Form Designer 
            'Do not modify it using the code editor. 
            InitializeComponent() 
        End Sub 
    
    #End Region 
    
        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
            Dim a As New ClProspetto 
            Dim oState As ClControlState 
            Response.Write(oState.Type) 
            For Each oState In a.oColControl 
                MapControl(oState) 
            Next 
    
        End Sub 
        Private Sub MapControl(ByVal oState As ClControlState) 
            Dim oHlp As System.Web.UI.Control 
    
            Select Case oState.Type 
                Case ClControlState.CtrlType.Button 
                    Dim oBtn As New Button 
    
                    oBtn.Height = New WebControls.Unit(oState.Height) 
                    oBtn.Width = New WebControls.Unit(oState.Width) 
    
                    oHlp = oBtn 
    
                Case ClControlState.CtrlType.Label 
                Case ClControlState.CtrlType.Listbox 
                Case ClControlState.CtrlType.Texbox 
                Case Else 
                    Exit Sub 
            End Select 
            Me.Controls.Add(oHlp) 
        End Sub 
    
    End Class

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.