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(B yVal sender As Object, ByVal e As
ConvertEventArg s)
If TypeOf e.Value Is Double Then
e.Value = CType(e.Value, Double).ToStrin g("p")
End If
End Sub
Private Sub CashFlow1Form_L oad(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles MyBase.Load
AddHandler Me.SalesGrowthC ombo.DataBindin gs("Text").Form at, AddressOf
Me.FormatNumber WithDecimals
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_L oad(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles MyBase.Load
Dim SalesGrowthItem s As New Binding("Text", DataSet1, "Growth
Rate Options.Growth Rate")
Add Handler SalesGrowthItem s.Format, AddressOf Me.FormatPercen t
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
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
---------------------------------------------------------- http://www.usenet.com 5 3625
Two solution as I see it.
1: Add a new column in your dataset that contains the formatted text you
want in the combobox. (If you populate the Dataset from SQL, this is very
easy to do)
2: Loop through the rows in the dataset and add them to the combo box
yourself, formatting as you go.
Both are easy to do. If you need more help, just let us know.
Chris
"Carrie" <ca*******@hotm ail-dot-com.no-spam.invalid> wrote in message
news:42******** @127.0.0.1... 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(B yVal sender As Object, ByVal e As ConvertEventArg s) If TypeOf e.Value Is Double Then e.Value = CType(e.Value, Double).ToStrin g("p") End If End Sub
Private Sub CashFlow1Form_L oad(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load AddHandler Me.SalesGrowthC ombo.DataBindin gs("Text").Form at, AddressOf Me.FormatNumber WithDecimals
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_L oad(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load Dim SalesGrowthItem s As New Binding("Text", DataSet1, "Growth Rate Options.Growth Rate") Add Handler SalesGrowthItem s.Format, AddressOf Me.FormatPercen t
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
Posted Via Usenet.com Premium Usenet Newsgroup Services ---------------------------------------------------------- ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY ** ---------------------------------------------------------- http://www.usenet.com
I use the method Chris proposed all the time. As he said it's easy. Give it
a try and let us know the results.
"Carrie" wrote: 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(B yVal sender As Object, ByVal e As ConvertEventArg s) If TypeOf e.Value Is Double Then e.Value = CType(e.Value, Double).ToStrin g("p") End If End Sub
Private Sub CashFlow1Form_L oad(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load AddHandler Me.SalesGrowthC ombo.DataBindin gs("Text").Form at, AddressOf Me.FormatNumber WithDecimals
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_L oad(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load Dim SalesGrowthItem s As New Binding("Text", DataSet1, "Growth Rate Options.Growth Rate") Add Handler SalesGrowthItem s.Format, AddressOf Me.FormatPercen t
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
Posted Via Usenet.com Premium Usenet Newsgroup Services ---------------------------------------------------------- ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY ** ---------------------------------------------------------- http://www.usenet.com
I've used Format and Parse events to even format a picture, so it handles
DBNull values, and displays a predefined "no picture" picture. This is the
most ".net" approach, since .net is an event-oriented platform, and it gets
your code the most clean.
In the Format event, you receive each value, and you format it to display in
the control. In the Parse event, you "un-format" the value to save it to the
database. You only have to transform these values, and don't have to worry
for which rows are shown. This is done by the binding.
I suggest this approach.
Hope this helps.
VBen.
"Carrie" <ca*******@hotm ail-dot-com.no-spam.invalid> escribió en el mensaje
news:42******** @127.0.0.1... 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(B yVal sender As Object, ByVal e As ConvertEventArg s) If TypeOf e.Value Is Double Then e.Value = CType(e.Value, Double).ToStrin g("p") End If End Sub
Private Sub CashFlow1Form_L oad(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load AddHandler Me.SalesGrowthC ombo.DataBindin gs("Text").Form at, AddressOf Me.FormatNumber WithDecimals
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_L oad(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load Dim SalesGrowthItem s As New Binding("Text", DataSet1, "Growth Rate Options.Growth Rate") Add Handler SalesGrowthItem s.Format, AddressOf Me.FormatPercen t
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
Posted Via Usenet.com Premium Usenet Newsgroup Services ---------------------------------------------------------- ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY ** ---------------------------------------------------------- http://www.usenet.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Newbee |
last post by:
Hola
I wanted to kno how to clear the current text that is displayed in my combobox
I am filling it with a query which is run against my database
I have tried this but it not work
Combobox1.text = "
am i using the wrong event
|
by: Carrie |
last post by:
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)
|
by: Robert |
last post by:
I'm sure this is a fairly basic question, but I've been looking all over the
web for days for suggestions on how to do this.
I've got a datagrid that's bound to a dataset on my form. It includes
several columns, the last of which (with the header Quantity) contains int16
values. When a user selects a row, I would like to have a combobox on the
form display the values from 1 to the number in the Quantity column (e.g.,
the selected row has...
|
by: Doug |
last post by:
This is a repost of an item that I still cannot resolve.
I have 3 combo boxes. The first leads to the second to the third.
When I have selected a value in the second box, the third box shows the
available information based on the second combo box selection. But if I
change my mind and select a different item in the second box, after the
third box has been populated, the third box still retains the information
that was previously...
|
by: pmcguire |
last post by:
I have derived a ComboBoxColumnStyle that inherits DataGridColumnStyle. It works fine except for one behavior. If the user selects a new value from the ComboBox's pulldown list on a brand new record, the ComboBoxColumn's Commit event doesn't fire. If the user first edits a TextBox cell on the same New row, and THEN selects a new value for the ComboBox cell, Commit fires. What is going on and how do I get around it
Thanks
Pat
| |
by: Sakharam Phapale |
last post by:
Hi All,
How to fill one ComboBox from other ComboBox control?
1) Only setting the reference does the trick but doesn't show items in
control. If you see in immediate window, it shows the item count correctly
|
by: Matt |
last post by:
I'm not entirely sure how to describe this issue. I have a number of
ComboBoxes in my application which have their text properties bound to a
field in a data set. The items loaded in the ComboBox are not data bound
(they just use the built in collection property of the ComboBox), and
they are all set to use the DropDownList style. When moving from record
to record via a BindingNavigator or a DataGridView (in master/detail
format), the text...
|
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= |
last post by:
I want to create a customized ComboBox where the methods ComboBox.Items.Add
and ComboBox.Items.Insert will behave thusly:
-- If the item is not present, add it.
-- If the item is present, set the selected index to the item (without
adding a duplicate).
I know the basics of inheriting from user controls, so if this was merely
overriding a method of ComboBox I could do it. But how does one go about
overriding a method of the Items...
|
by: Jerad Rose |
last post by:
I'm baffled by this -- is there not a typed object used for ComboBox Items?
Best I can tell, all of the methods for ComboBox that accept an Item are of
type Object. Why in the world is a common/standard .NET control accepting
an Object as a parameter type?
In Web Forms, there is a ListItem object that can be passed in to
add/retrieve objects from a DropDownItems collection. I searched Google
groups, and all the solutions I'm finding...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |