C# 中的 tTable 单元格和行边框在每条边上都不同

发布于 2024-08-29 18:10:57 字数 203 浏览 1 评论 0原文

我试图在表格中动态生成报告,其中单元格或行每一侧的边框都不同,但不知道如何实现。 TableRow、TableCell 和 Table 对象均具有 BorderStyle 属性,但它似乎适用于整个边框而不仅仅是一侧。这可以在没有嵌套表的情况下完成吗?

对于我的情况,我希望在表格的前两行周围有一个实心边框(因为第一行有一个跨越两行的单元格),并在每个后续行周围有一个实心边框。

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 border 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

擦肩而过的背影 2024-09-05 18:10:57

这看起来像是 CSS 的工作。

ASP.net 控件中的边框控件可能很笨重,甚至会误导使用。我建议向您的行和/或单元格添加一些 CssStyles,如下所示:

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

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

并在 CSS 标记内定义边框,如下所示:

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

至少这将使您对边框的布局有更多的控制。如果您需要表格边框的良好 CSS 参考,我会在此处查看 W3.org 页面

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文