gpt4 book ai didi

c# - 如何在devexpress XtraGrid中设置背景颜色

转载 作者:行者123 更新时间:2023-11-30 17:03:05 25 4
gpt4 key购买 nike

我想设置devexpress winforms grid的背景色。

这是我调用的方法。

在表单加载时..

LoadCodes(); - returns a dataset which is used in gridView rowstyle method.

gridView1.RefreshData();

private void gridView1_RowStyle(object sender, RowStyleEventArgs e)
{
string code=string.Empty;
for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
{
code = View.GetRowCellDisplayText(e.RowHandle, View.Columns["code"]);
if (code.Trim() == ds.Tables[0].Rows[i]["code"].ToString().Trim())
{
e.Appearance.BackColor = Color.LightBlue;
e.Appearance.BackColor2 = Color.WhiteSmoke;
}
}

}

我该如何处理这个问题,或者有其他方法可以处理这个问题吗?

Issue: The code doesn't throw any error, however i don't see rowsgetting the background color automatically, after the form is loaded,however when i click on any row of the grid (after the form is loaded, grid data is visible), then i get to see the background color.

最佳答案

您必须通过在 e.Appearance.Options 上设置它来告诉 DevExpress 哪些 Appearance 属性应该生效

在你的情况下 e.Appearance.Options.UseBackColor = true

详情请见:http://documentation.devexpress.com/#windowsforms/DevExpressUtilsAppearanceOptionsMembersTopicAll

注意:当您为 EvenRowOddRow 定义样式时,您还必须设置 e.HighPriority(参见:http://documentation.devexpress.com/#windowsforms/DevExpressXtraGridViewsGridRowStyleEventArgs_HighPrioritytopic)

关于c# - 如何在devexpress XtraGrid中设置背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19016027/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com