Click here to Skip to main content
15,895,538 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
private void Window_Loaded_1(object sender, RoutedEventArgs e)
       {
           int ymax = 300;
           parentchart.Axes.Add(new LinearAxis() { Minimum = 0, Orientation=AxisOrientation.Y, Maximum = ymax > 0 ? ymax : 500 });
           for (int i = 0; i <= ymax; i++)
           {
               txty.Text = i.ToString();
               cmb.Items.Add(i.ToString());
               cmb.DisplayMemberPath = i.ToString();


           }


value of i is not displaying in combobox ...
Posted
Comments
Alexander Dymshyts 5-Nov-13 2:34am    
do you notify your combobox that property has been changed?
kumar9avinash 5-Nov-13 3:32am    
@alxender ,i am new to wpf can u tell me how to do it.(or he code of xaml)

Remove the line "cmb.DisplayMemberPath = i.ToString();"

You are using incorrectly "DisplayMemberPath"
Please, check this link:
http://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol.displaymemberpath(v=vs.100).aspx[^]
 
Share this answer
 
v2
C#
private void Window_Loaded_1(object sender, RoutedEventArgs e)
       {
           List<int> lst = new List<int>() { 1,2,3,4,5,6,7,8,9,10};

           cmbSelect.ItemsSource = lst; // first method
           cmbSelect.SelectedIndex = 0;

          (or)

           foreach (var item in lst)//second method
           {
               cmbSelect.Items.Add(item);
           }
           cmbSelect.SelectedIndex = 0;
        }


Hope it helps you ...
 
Share this answer
 
v2
Comments
kumar9avinash 5-Nov-13 7:29am    
yes it worked

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