How do I use a ValueConverter with Databinding in Winforms

后端 未结 2 2046
攒了一身酷
攒了一身酷 2021-02-14 05:31

In WPF it is easy to use a ValueConverter to format values etc, (in our case convert some numbers into a different unit, e.g km to miles)

I know it can be done in Winf

2条回答
  •  無奈伤痛
    2021-02-14 05:42

    Another option is to have a specific ViewModel for the form which exposes data in the format you need to display on the form. You can easily achieve it by using AutoMapper and building your own Formatter.

    This way you will have full support for designer too.

提交回复
热议问题