By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,569 Members | 1,394 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,569 IT Pros & Developers. It's quick & easy.

.net table control

P: n/a
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
Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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
"Rob Meade" <ro********@NO-SPAM.kingswoodweb.net> wrote in message
news:MD*********************@news-text.cableinet.net...
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

Nov 18 '05 #2

P: n/a
"Nicole Calinoiu" wrote ...
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 :o)

Rob
Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.