开发者

Winforms Individually Format Double Values in ComboBox

开发者 https://www.devze.com 2023-04-07 16:42 出处:网络
I need to individually format items in a combo box in C#/Winforms. The combo box contains a set of doubles taken from a set of objects assigned to it (e.g., 1, 1.01, 1.02, 1.03 etc.)

I need to individually format items in a combo box in C#/Winforms. The combo box contains a set of doubles taken from a set of objects assigned to it (e.g., 1, 1.01, 1.02, 1.03 etc.)

What I need to do is format them so that the read (1.0, 1.01, 1.02, 1.03 etc.) not (1.00, 1.01, 1.02 etc.)

I know that the format string property can be used to for开发者_开发问答mat the whole collection, but is there a way to do some form of conditional formatting on the item collection by crating a user control?


You can format each item individually by supplying a handler for the Format event.

The event handler looks like this:

private void comboBox1_Format(object sender, ListControlConvertEventArgs e)

You can then modify e.Value as you so wish.

0

精彩评论

暂无评论...
验证码 换一张
取 消