.net table control

R

Rob Meade

Hi all,

I'm trying to add a table row, and cell to the row and also set the colour
of the cell, I seem only able to do this with the pre-defined colours - I
cant for example use #cc66cc ...

tblHeader.Width.Percentage(100%)

Dim Row As New TableRow
Dim Cell As New TableCell

Cell.Text = "<img src=""../Images/Misc/invis.gif"" width=""10""
height=""10"" border=""0"">"
Cell.BackColor = Cell.BackColor.DarkKhaki()
Cell.Width.Percentage(100%)

tblHeader.Rows.Add(Row)
Row.Cells.Add(Cell)

In addition - I also seem unable to set any of the properties for the table
itself, the width 100% at the top here for example doesn't do what I
expected...

In normal HTML if I set a table to 100% and then had one row with one cell,
the cell would also be 100% - this isn't happening :(

Any info would be appreciated, I've search google for a bit and tried the
help within Visual Studio but no joy thus far...the only examples I can find
seem to be on how to add the rows and cells, not how to change their display
settings etc..

Regards

Rob
 
N

Nicole Calinoiu

Rob,

You can use the System.Drawing.ColorTranslator class to create a Color
instance from an HTML color string. e.g.:

Cell.BackColor = ColorTranslator.FromHtml("#cc66cc")


To set the width of the cell or table to a percentage value, use the
Percentage method of the System.Web.UI.WebControls.Unit structure. e.g.:

tblHeader.Width = Unit.Percentage(100)

HTH,
Nicole
 
R

Rob Meade

...
You can use the System.Drawing.ColorTranslator class to create a Color
instance from an HTML color string. e.g.:

Cell.BackColor = ColorTranslator.FromHtml("#cc66cc")


To set the width of the cell or table to a percentage value, use the
Percentage method of the System.Web.UI.WebControls.Unit structure. e.g.:

tblHeader.Width = Unit.Percentage(100)

Hi Nicole,

Many thanks for your informative reply - these have indeed solve my
troubles...thank you :blush:)

Rob
 

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

Top