Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi All,

Is there a way to load the combobox with values like 0%,20% ,40%..In my case i am loading the values from a Datatable. Here is my code

VB
Private m_dtPercentofSales As New DataTable
m_dtEstDelayedDeliveryPercentofSales = GetPercentofSales()
        For Each dr As DataRow In m_dtPercentofSales.Rows
            Me.cmbPercentofSales.Items.Add(dr("PercentofSales"))
        Next



Please help.Thanks.
Posted
Updated 16-May-13 6:44am
v2
Comments
Sergey Alexandrovich Kryukov 16-May-13 12:42pm    
"Percentage value" still means some string, no different from any other... and you can store anything in the ComboBox elements...
So, what's the problem?..
—SA
vidkaat 16-May-13 13:41pm    
No i want to display them as 20% ...not 20 ...I get these from the Datatable ...So how do i do that?

Sergey Alexandrovich Kryukov 16-May-13 14:15pm    
Same thing! Anyway, what's the problem?
—SA

1 solution

The combo can only ever show a string, unless of course, you paint the combo yourself.

So, if it's a string you're adding, why not just do this:
cmdPectentageofSales.Items.Add(dr("PercentageofSales").ToString() + "%");

Really, how hard was that?
 
Share this answer
 
Comments
Maciej Los 16-May-13 15:51pm    
+5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900