【问题标题】:How to change a button backcolor in ObjectListView如何更改 ObjectListView 中的按钮背景色
【发布时间】:2016-05-05 06:14:59
【问题描述】:

我有一个 ObjectListView 并设置了 1 列

 IsButton=True

我想改变按钮背景色,但是没有办法设置。

请有人帮我解决这个问题。

【问题讨论】:

    标签: c# objectlistview


    【解决方案1】:

    我从 objectlistview 网站得到了下面的代码,告诉我它是否有帮助

    要更改单个单元格的格式,您需要将 UseCellFormatEvents 设置为 true,然后侦听 FormatCell 事件。要仅以红色显示贷方余额,您可以执行以下操作:

    private void olv1_FormatCell(object sender, FormatCellEventArgs e) {
        if (e.ColumnIndex == this.creditBalanceColumn.Index) {
            Customer customer = (Customer)e.Model;
            if (customer.Credit < 0)
                e.SubItem.ForeColor = Color.Red;
        }
    }
    

    【讨论】:

    • 感谢您回答我的问题,我试过了,但是没有用。可能按钮列与普通单元格不一样。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-06-04
    • 1970-01-01
    • 2023-03-19
    • 2019-10-29
    • 2021-12-14
    • 1970-01-01
    相关资源
    最近更新 更多