471,318 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,318 software developers and data experts.

Combobox - Format Items

Good Afternoon,

I have a combobox whose list is bound to DataSet1.Sales Growth Options.Sales
Growth. The data is double and I would like it displayed as a percentage. I
have tried two things:

1. I bound the data using DataSource and DisplayMember and then used the
following code:

Private Sub FormatPercent(ByVal sender As Object, ByVal e As ConvertEventArgs)
If TypeOf e.Value Is Double Then
e.Value = CType(e.Value, Double).ToString("p")
End If
End Sub

Private Sub CashFlow1Form_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
AddHandler Me.SalesGrowthCombo.DataBindings("Text").Format, AddressOf
Me.FormatNumberWithDecimals

The result is that the first item in the list was formatted correctly, but
the drop-down list of items when you pressed the arrow wasn't.

2. Then I tried eliminating the DataSource and DisplayMember values and
replacing it with the following:

Private Sub CashFlow1Form_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim SalesGrowthItems As New Binding("Text", DataSet1, "Growth Rate
Options.Growth Rate")
Add Handler SalesGrowthItems.Format, AddressOf Me.FormatPercent

This resulted in only one item in my combobox. This one item was formatted.

If anybody could give me assistance, I would appreciate it.

Thanks,

Carrie

Jul 21 '05 #1
0 1015

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Doug | last post: by
5 posts views Thread by Carrie | last post: by
4 posts views Thread by Jerad Rose | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.