简体   繁体   English

Winform - 不是 WPF - ListView 货币和复选框与 C#

[英]Winform - Not WPF - ListView Currency and Checkbox with C#

Does anyone know how to add a currency to a specific column in ListView, please?请问有谁知道如何将货币添加到 ListView 中的特定列? It is easy with WPF but my project is Win form.使用 WPF 很容易,但我的项目是 Win 形式。

CheckBox I used this code for checkbox, but it only shows checkbox in the first Column. CheckBox我将此代码用于复选框,但它仅在第一列中显示复选框。 I want it on 5th Column我要在第 5 列

listView1.CheckBoxes = true;

Currency I tried this but it is not good.货币 我试过这个,但效果不好。

                ListViewItem viewItem = new ListViewItem(new string[]
                {

                    "£"+emailDetails.Total+".00"
                 });

ListView in WinForms is a very different animal than ListView in WPF. WinForms 中的 ListView 与 WPF 中的 ListView 完全不同。

For the currency : add a string property to your emailDetails class that formats the currency as desired.对于货币:将字符串属性添加到您的emailDetails class 以根据需要格式化货币。 I would recommend you format the value once, when you set the Total amount, and then reuse the formatted value in the getter of the new property.我建议您在设置 Total 金额时对值进行一次格式化,然后在新属性的 getter 中重用格式化的值。

For the checkbox : the only way to have it in a different column than the first is to do custom drawing and draw the combobox yourself.对于复选框:将其放在与第一个不同的列中的唯一方法是进行自定义绘图并自己绘制 combobox。 It is more complicated, as you will need to perceive clicks to change the picture of the box, and store the status of every checkbox somewhere.它更复杂,因为您需要感知点击以更改框的图片,并将每个复选框的状态存储在某处。

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

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