简体   繁体   English

DataGridView 中的交替颜色 For windows 窗体

[英]Alternating colors in DataGridView For windows form

如何在 DataGridView 中设置交替颜色?

Set the alternating row style is the easiest.设置交替行样式是最简单的。 If you need more control, you can set it using the row binding event with a custom algorithm.如果您需要更多控制,您可以使用带有自定义算法的行绑定事件来设置它。 I don't think you need to do that, however.但是,我认为您不需要这样做。 If you want something complex, I would suggest buying a third party control library, as they handle the complex scenarios without a lot of coding.如果您想要一些复杂的东西,我建议您购买第三方控件库,因为它们无需大量编码即可处理复杂的场景。

Just saw you were doing win forms.刚刚看到你在做胜利表格。 Still pretty much the same thing.仍然几乎相同的事情。 Set the alternating row.设置交替行。 And, there are more complex grids out there you can purchase.而且,您可以购买更复杂的网格。 So the answer still holds for the most part.所以答案在很大程度上仍然成立。

Using a theme for the gridview ;) Read it here:MSDN为 gridview 使用主题 ;)在这里阅读:MSDN

EXAMPLE:例子:

a skin file example:皮肤文件示例:

<asp:GridView runat="server" CssClass="DataWebControlStyle"> <AlternatingRowStyle CssClass="AlternatingRowStyle" /> <RowStyle CssClass="RowStyle" /> <HeaderStyle CssClass="HeaderStyle" /> <SelectedRowStyle CssClass="SelectedRowStyle" /> <PagerStyle CssClass="PagerStyle" /> <PagerSettings Mode="NumericFirstLast" PageButtonCount = "5" /> </asp:GridView>

CSS: ' .AlternatingRowStyle { background-color: #A9D0F5; CSS: ' .AlternatingRowStyle { 背景颜色: #A9D0F5; } }

.RowStyle { background-color: #E0E0F8; .RowStyle { 背景色:#E0E0F8; } }

.SelectedRowStyle { background-color: #2E2EFE; .SelectedRowStyle { 背景色:#2E2EFE; } }

' '

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM