gpt4 book ai didi

c# - 隐藏 DataGridViewImageColumn 中的图像

转载 作者:行者123 更新时间:2023-12-03 22:18:35 26 4
gpt4 key购买 nike

我需要隐藏或显示 DataGridViewImageColumn 中单个单元格的图像。我将代码放在单元格格式化事件中。但我不知道如何从细胞中隐藏图像。我知道如何删除图像的唯一方法是首先将图像列的图像属性设置为 null,然后将每个单元格的图像设置为一些图像以供显示。但这有点不方便,因为图像显示/隐藏代码现在在我的单元格格式化事件中。

有人知道从单个单元格中隐藏/删除图像的简单方法吗?谢谢。

最佳答案

我只是在寻找同一问题的解决方案,我已经解决了以下问题:

if (showImage == true)
{
imageCell.Value = new Bitmap(iconPath);
}
else
{
imageCell.Value = new Bitmap(1, 1);
}

如果您的单元格背景为白色,则 1x1 位图将不可见。否则,您必须根据需要为该像素着色。

关于c# - 隐藏 DataGridViewImageColumn 中的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4893662/

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