I'll check it out!
I have been using this in the interim, but i didn't know if there was a
bettre way (less code):
Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.WebControls
<DefaultProperty("Text"), ToolboxData("<{0}:TekTable
runat=server></{0}:TekTable>")> Public Class TekTable
Inherits System.Web.UI.WebControls.WebControl
Dim _text As String
Dim intMaxCols As Integer
Dim intMaxWidth As Integer
Dim alUC As New ArrayList
<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
<Bindable(True), Category("Appearance"), DefaultValue("3")> Property
myMaxCols() As Integer
Get
Return intMaxCols
End Get
Set(ByVal Value As Integer)
intMaxCols = Value
End Set
End Property
<Bindable(True), Category("Appearance"), DefaultValue("800")> Property
myMaxWidth() As Integer
Get
Return intMaxWidth
End Get
Set(ByVal Value As Integer)
intMaxWidth = Value
End Set
End Property
<Bindable(True), Category("Appearance"), DefaultValue("")> Property myUC()
As ArrayList
Get
Return alUC
End Get
Set(ByVal Value As ArrayList)
alUC = Value
End Set
End Property
Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
If Me.alUC.Count <> 0 Then
Dim tbl As New Table
Dim uc As UserControl
Dim r As TableRow
Dim c As TableCell
Dim int As Integer
Dim booAdded As Boolean = False
Dim i As Integer = 1
For int = 0 To alUC.Count - 1
booAdded = False
If i = 1 Then
r = New TableRow
End If
c = New TableCell
c.VerticalAlign = VerticalAlign.Top
c.Controls.Add(alUC.Item(int))
r.Cells.Add(c)
If i = intMaxCols Then
tbl.Rows.Add(r)
booAdded = True
i = 0
End If
i += 1
tbl.Rows.Add(r)
Next
If booAdded = False Then
tbl.Rows.Add(r)
End If
Me.Controls.Add(tbl)
End If
output.Write(Me.[Text])
Me.RenderChildren(output)
End Sub
Kevin
"Cor" <no*@non.com> wrote in message
news:eK**************@TK2MSFTNGP10.phx.gbl...
Hi A,
I was curious if something that I made for a winform would work on a
webform too, here an example (changed for a webform).
It is a calender, of course you can better use the calandercontrol, but as
example it is fine
\\\
Private mybutton(31) As Button
Private mylabel As New Label
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As Integer
For i = 0 To System.DateTime.DaysInMonth(2003, 11) - 1
mybutton(i) = New Button
mybutton(i).BackColor = Drawing.Color.AntiqueWhite
mybutton(i).Text = (i + 1).ToString
mybutton(i).Width = New Unit(30)
Me.panel1.Controls.Add(mybutton(i))
AddHandler mybutton(i).Click, AddressOf mybutton_Click
If (i + 1) Mod 5 = 0 Then
Me.panel1.Controls.Add(New LiteralControl("<BR>"))
End If
Next
Me.panel1.Controls.Add(New LiteralControl("<BR><BR>"))
Me.panel1.Controls.Add(mylabel)
End Sub
Private Sub mybutton_Click _
(ByVal sender As Object, ByVal e As System.EventArgs)
Dim day As Button = DirectCast(sender, Button)
mylabel.Text = "The day is: " & day.Text
End Sub
///
Here is a link also,
http://msdn.microsoft.com/library/de...satruntime.asp
I hope this helps a little bit?
Cor
I have a specific problem, but a general answer may help. I am building
aweb app which will display multiple UserControls on the screen. I want
toput them in a table that is X Columns by however many rows it takes to
complete the list.
I essentially need to add dim a new row, then a new cell, and continue
adding cells to the row until i get to the max_rows property, then add
thatrow to the table, dim a new row, and continue.
Is there any easy way of doing this with methods of arrays or arraylists,
ordo I need to write out raw code? Any ideas or snippets??