Panel and dymanic table

A

anonymous

On a run time I am generating a table inside a panel.
The table alsways generated to the left and I wanted to be
in canter of the panel.
How do I find the center of the panel and add the table?
 
K

Ken Cox [Microsoft MVP]

You can set the alignment of the panel contents using
HorizontalAlign.Center. Here's some code that dynamically creates a table
inside a panel.

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim pnl As New Panel
Dim tbl As New Table
Dim rw As TableRow
Dim cll As TableCell
PlaceHolder1.Controls.Add(pnl)
pnl.HorizontalAlign = HorizontalAlign.Center
rw = New TableRow
rw.BorderColor = System.Drawing.Color.Beige
rw.BorderWidth = Unit.Pixel(2)
cll = New TableCell
cll.Text = "one"
rw.Controls.Add(cll)
cll = New TableCell
cll.Text = "two"
rw.Controls.Add(cll)
tbl.Controls.Add(rw)
tbl.GridLines = GridLines.Both
pnl.Controls.Add(tbl)
End Sub
 
A

anonymous

Thank you.
I have one more questions. If in a panel I have static
grid and dynamic table and sometimes my grid is empty and
I am not displaying it, but I would like to have my
dymanic table dysplayed in a start position where grid is.
Right now ot is always displaying after the grid even the
grid is invisible.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,141
Messages
2,570,818
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top