C
Carrie
Good Morning,
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
Expand AllCollapse All
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
Expand AllCollapse All