开发者

tTable cell and row borders different on each edge in C#

开发者 https://www.devze.com 2022-12-27 07:52 出处:网络
I\'m trying to dynamically generate a report in a table where the borders are different on each side of a cell or row, but can\'t figure out how.The TableRow, TableCell, and Table objects each have a

I'm trying to dynamically generate a report in a table where the borders are different on each side of a cell or row, but can't figure out how. The TableRow, TableCell, and Table objects each have a BorderStyle property, but it seems to apply to the entire border rather than just one side. Can this be done without nesting tables?

For my case, I'd like a solid borde开发者_如何学Pythonr around the first two rows of a table (because the first row has a cell spanning two rows), and a solid border around each subsequent row.


This looks like a job for CSS.

The border controls within the ASP.net controls can be chunky and mis-leading to use at best. I would suggest adding some CssStyles to your rows and or cells like this:

    TableRow row1 = new TableRow();
    row1.CssClass = "rowStyle1";

    TableCell cell1 = new TableCell();
    cell1.CssClass = "cellStyle1";

And defining up your borders within the CSS tags like this:

rowStyle1      { border-collapse: collapse;
                 border: 1px solid black; }
etc...

At the very least this will give you a lot more control over the layout of your borders. If you need a good CSS refrence for table borders I would check out the W3.org page here

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号