System.Web.UI.WebControls
24/08/2006
0
Amigos estou manando um codigo exemplo do que quero fazer com um webcontrol, na verdade eu quero um conteiner que tenha 3 dropdownlist e um textbox,que possam ser criados dinamicamente,para isto eu achei melhor herdar da table para o container e os itens herdando das linhas, que e na verdade tablerow com 4 celulas.Agora o problema eu o coloco no form mas ele não rederisa, fica como se não tivese nem um controle.
se alguem puder me ajudar eu fico grato.
Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.WebControls
# Region ´Controle Conteiner´
<DefaultProperty(´Text´), ToolboxData(´<:NomeDoControle runat=server></:NomeDoControle>´)> Public Class NomeDoControle
Inherits System.Web.UI.WebControls.Table
Dim _text As String
Dim _DataSource As Object
<Bindable(True), Category(´Appearance´), DefaultValue(´´)> Property [Text]() As String
Get
Return _text
End Get
Set(ByVal Value As String)
_text = Value
End Set
End Property
Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
output.Write(output)
End Sub
Public Sub Add(ByVal ItemControle As ItemNomeDoControle)
MyBase.Rows.Add(ItemControle)
MyBase.CreateChildControls()
End Sub
Public Sub Add(ByVal ListDeValores As ListItemCollection)
Dim ItemControle As New ItemNomeDoControle(ListDeValores)
MyClass.Add(ItemControle)
End Sub
Public Sub New()
Me.EnsureChildControls()
End Sub
End Class
#end region
Region ´ItemDoControle´
<DefaultProperty(´Text´), ToolboxData(´<:ItemNomeDoControle runat=server></:NomeDoControle>´)> Public Class ItemNomeDoControle
Inherits System.Web.UI.WebControls.TableRow
Dim _text As String
Public Event ChanceCombo3(ByVal Sender As Object, ByVal e As EventArgs)
Private combo0 As DropDownList
Private combo1 As DropDownList
Private TextBox As TextBox
Private WithEvents combo2 As DropDownList
<Bindable(True), Category(´Appearance´), DefaultValue(´´)> Property [Text]() As String
Get
Return _text
End Get
Set(ByVal Value As String)
_text = Value
End Set
End Property
Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
output.Write(output)
End Sub
Public Sub New(ByVal ListaCampos As ListItemCollection)
combo0 = New DropDownList
combo1 = New DropDownList
textbox = New TextBox
combo2 = New DropDownList
Dim C1 As New TableCell
Dim C2 As New TableCell
Dim C3 As New TableCell
Dim C4 As New TableCell
Dim I As Integer = 0
For I = 0 To ListaCampos.Count - 1
combo0.Items.Add(ListaCampos.Item(0))
Next
combo1.Items.Add(´ valor1 ´)
combo1.Items.Add(´ valor2 ´)
combo1.Items.Add(´ valor3 ´)
combo2.Items.Add(´ 0 ´)
combo2.Items.Add(´ 1 ´)
combo2.Items.Add(´ 2 ´)
C1.Controls.Add(combo0)
C2.Controls.Add(combo1)
C3.Controls.Add(textbox)
C4.Controls.Add(combo2)
AddHandler combo3.SelectedIndexChanged, AddressOf OnChanceCombo3
Me.Cells.Add(C1)
Me.Cells.Add(C2)
Me.Cells.Add(C3)
Me.Cells.Add(C4)
Me.CreateChildControls()
End Sub
Sub OnChanceCombo3(ByVal Sender As Object, ByVal e As EventArgs)
RaiseEvent ChanceCombo3(Sender, e)
End Sub
End Class
#End Region
se alguem puder me ajudar eu fico grato.
Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.WebControls
# Region ´Controle Conteiner´
<DefaultProperty(´Text´), ToolboxData(´<:NomeDoControle runat=server></:NomeDoControle>´)> Public Class NomeDoControle
Inherits System.Web.UI.WebControls.Table
Dim _text As String
Dim _DataSource As Object
<Bindable(True), Category(´Appearance´), DefaultValue(´´)> Property [Text]() As String
Get
Return _text
End Get
Set(ByVal Value As String)
_text = Value
End Set
End Property
Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
output.Write(output)
End Sub
Public Sub Add(ByVal ItemControle As ItemNomeDoControle)
MyBase.Rows.Add(ItemControle)
MyBase.CreateChildControls()
End Sub
Public Sub Add(ByVal ListDeValores As ListItemCollection)
Dim ItemControle As New ItemNomeDoControle(ListDeValores)
MyClass.Add(ItemControle)
End Sub
Public Sub New()
Me.EnsureChildControls()
End Sub
End Class
#end region
Region ´ItemDoControle´
<DefaultProperty(´Text´), ToolboxData(´<:ItemNomeDoControle runat=server></:NomeDoControle>´)> Public Class ItemNomeDoControle
Inherits System.Web.UI.WebControls.TableRow
Dim _text As String
Public Event ChanceCombo3(ByVal Sender As Object, ByVal e As EventArgs)
Private combo0 As DropDownList
Private combo1 As DropDownList
Private TextBox As TextBox
Private WithEvents combo2 As DropDownList
<Bindable(True), Category(´Appearance´), DefaultValue(´´)> Property [Text]() As String
Get
Return _text
End Get
Set(ByVal Value As String)
_text = Value
End Set
End Property
Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
output.Write(output)
End Sub
Public Sub New(ByVal ListaCampos As ListItemCollection)
combo0 = New DropDownList
combo1 = New DropDownList
textbox = New TextBox
combo2 = New DropDownList
Dim C1 As New TableCell
Dim C2 As New TableCell
Dim C3 As New TableCell
Dim C4 As New TableCell
Dim I As Integer = 0
For I = 0 To ListaCampos.Count - 1
combo0.Items.Add(ListaCampos.Item(0))
Next
combo1.Items.Add(´ valor1 ´)
combo1.Items.Add(´ valor2 ´)
combo1.Items.Add(´ valor3 ´)
combo2.Items.Add(´ 0 ´)
combo2.Items.Add(´ 1 ´)
combo2.Items.Add(´ 2 ´)
C1.Controls.Add(combo0)
C2.Controls.Add(combo1)
C3.Controls.Add(textbox)
C4.Controls.Add(combo2)
AddHandler combo3.SelectedIndexChanged, AddressOf OnChanceCombo3
Me.Cells.Add(C1)
Me.Cells.Add(C2)
Me.Cells.Add(C3)
Me.Cells.Add(C4)
Me.CreateChildControls()
End Sub
Sub OnChanceCombo3(ByVal Sender As Object, ByVal e As EventArgs)
RaiseEvent ChanceCombo3(Sender, e)
End Sub
End Class
#End Region
Rogeriorock
Curtir tópico
+ 0
Responder
Posts
25/08/2006
Rogeriorock
Bem, estou aqui brigando ainda rsrs, mas ja tive algum avanço, bem para rederizar o componente e a coisa mas obvia do mundo, chamar o render do mybase como a baixo.
Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
mybase.Render(output)
End Sub
Mas ainda estou precisso de ajuda, pq ele redereriza,mas não perciste, quer dizer ele cria a primeira linha otimo, mas quando vou adicionar a segunda linha ela não perciste e fica sempre com um. se puderem me ajudar fico grato
Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
mybase.Render(output)
End Sub
Mas ainda estou precisso de ajuda, pq ele redereriza,mas não perciste, quer dizer ele cria a primeira linha otimo, mas quando vou adicionar a segunda linha ela não perciste e fica sempre com um. se puderem me ajudar fico grato
Responder
Clique aqui para fazer login e interagir na Comunidade :)