visual-studio 在网格上显示网格线

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2420178/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 11:38:47  来源:igfitidea点击:

Show Gridlines on a Grid

c#asp.netvisual-studiotelerikradgrid

提问by Eric

I'm using Rad Grids and I use the built in Skins for appearance. However, I 'd like to add Gridlines for my Grid. Gridlines = "Both" does not seem to work.

我正在使用 Rad Grids,我使用内置的外观来制作外观。但是,我想为我的网格添加网格线。Gridlines = "Both" 似乎不起作用。

 <telerik:RadGrid ID="RadGridProviders" Width="100%" GridLines="Both" AllowPaging="true" Skin="WebBlue" runat="server"  DataSourceID="SDSProvider" AutoGenerateColumns="false">
                    <MasterTableView DataSourceID="SDSProvider" PageSize="7" CellPadding="0" GridLines="Both" CellSpacing="0" DataKeyNames="ID,Entry_Loc" AllowMultiColumnSorting="True" AutoGenerateColumns="false"  >
                     <PagerStyle Mode="NextPrevNumericAndAdvanced"/>
                     <Columns>
                        <telerik:GridBoundColumn HeaderText="Organization Name" HeaderStyle-HorizontalAlign="Center" DataField="OrgName" SortExpression="OrgName">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Provider Type" HeaderStyle-HorizontalAlign="Center" DataField="TypeofProvider" SortExpression="TypeofProvider">
                        </telerik:GridBoundColumn>
                         <telerik:GridBoundColumn HeaderText="Contact Name" HeaderStyle-HorizontalAlign="Center" DataField="Contact" SortExpression="Contact">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Address" HeaderStyle-HorizontalAlign="Center" DataField="Address" SortExpression="Address">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Contact Number" HeaderStyle-HorizontalAlign="Center" DataField="Phone" SortExpression="Phone">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Creator Location" Visible="false" HeaderStyle-HorizontalAlign="Center" DataField="Entry_Loc" SortExpression="Entry_Loc">
                        </telerik:GridBoundColumn>
                        <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" HeaderText="Delete Provider" HeaderStyle-HorizontalAlign="Center" 
                            ConfirmText="Are You Sure You Want to Delete this Provider?" ConfirmDialogType="RadWindow" ConfirmTitle="Delete Provider Confirmation"
                            UniqueName="DeleteProv">
                        </telerik:GridButtonColumn> 
                     </Columns>
                    </MasterTableView>
                    </telerik:RadGrid>

I just tried adding custom CSS

我只是尝试添加自定义 CSS

.mytable tr td
    {
                border: solid 1px #000000;
    }

I set the css class for the item style inside of the masterr table, i set it on the master table and on the grid itself. Didn't work.

我在 masterr 表中为 item 样式设置了 css 类,我将它设置在 master 表和网格本身上。没用。

采纳答案by Andrew Bezzub

Your skin may not support grid lines. You can try using another skin to check this or use firebug. If skin does not support grid lines you will need to add them manually with custom css/skin.

您的皮肤可能不支持网格线。您可以尝试使用其他皮肤进行检查或使用 firebug。如果皮肤不支持网格线,您将需要使用自定义 css/skin 手动添加它们。

Here is description of RadGrid css classes: http://www.telerik.com/help/aspnet-ajax/grdcreatingnewskins.html

这里是 RadGrid css 类的描述:http: //www.telerik.com/help/aspnet-ajax/grdcreatingnewskins.html

You can try customizing existing skin or use something like:

您可以尝试自定义现有皮肤或使用以下内容:

.RadGrid_WebBlue .rgRow td
{
    border: solid 1px #000000;
}

回答by IrishChieftain

protected void Page_Load(object sender, EventArgs e)
{
    this.GridView1.Attributes.Add("bordercolor", "c3cecc");
}

"With the GridView, the declarative bordercolor attribute adds an inline style declaration which only applies to the table itself, not individual cells.

“在 GridView 中,声明性 bordercolor 属性添加了一个内联样式声明,该声明仅适用于表格本身,而不适用于单个单元格。

Adding the bordercolor attribute programmatically does not use an inline style, but uses the HTML bordercolor property, which browsers apply to ALL borders inside the table."

以编程方式添加 bordercolor 属性不使用内联样式,而是使用 HTML bordercolor 属性,浏览器将其应用于表格内的所有边框。”

This was a comment made by Lee Dumond on my blog post on this topic:

这是 Lee Dumond 在我关于此主题的博文中发表的评论:

http://codersbarn.com/post/2009/05/31/Set-Color-of-GridLines-in-Gridview.aspx

http://codersbarn.com/post/2009/05/31/Set-Color-of-GridLines-in-Gridview.aspx