gpt4 book ai didi

c# - 将字体更改为 DataGridView 行在 WinForms C# 中不起作用

转载 作者:太空宇宙 更新时间:2023-11-03 12:03:47 24 4
gpt4 key购买 nike

我有管理 datagridview 对象的方法:

internal static void LoadChannelsInGrid(DataGridView dg, Label noDataLbl, string feedUrl)
{
var response = RssManager.GetRss(feedUrl);
if (response != null)
{
noDataLbl.Visible = false;
dg.Visible = true;
var items = response.OrderByDescending(s => s.PubDateUnix);
dg.DataSource = items.ToArray();

FontifyDataGrid(dg);
}
else
{
noDataLbl.Visible = true;
dg.Visible = false;
}
}

private static void FontifyDataGrid(DataGridView dg)
{
for (var i = 0; i < dg.Rows.Count; i++)
{
var item = dg.Rows[i].DataBoundItem as ChannelData;
if (item == null)
{
continue;
}

if (!item.IsLoaded)
{
var actualFont = new Font("Microsoft Sans Serif", 7.8f, FontStyle.Bold);
dg.Rows[i].DefaultCellStyle.Font = actualFont;
}
}
}

我调用:

LoadChannelsInGrid(dataGridView1, noDataLbl, "https://....");

似乎行(哪个模型项满足 IsLoaded 值)没有粗体样式,看起来仍然很规则。

为什么?

最佳答案

如果我没理解错的话,当 IsLoaded 属性为真时,您需要将字体设置为粗体。

在这种情况下,您需要将 if (!item.IsLoaded) 更新为 if (item.IsLoaded)

关于c# - 将字体更改为 DataGridView 行在 WinForms C# 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55999373/

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