Click here to Skip to main content
16,015,594 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 = 500;
      parentchart.Axes.Add(new LinearAxis() { Minimum = 0, Orientation=AxisOrientation.Y, Maximum = ymax > 0 ? ymax : 300 });
      txty.Text = ymax.ToString();
      List<int> inp = new List<int>();
      for (int i = 0; i <= ymax; i++)
         {
            inp.Add(i);
            textbox.Text = inp.ToString();
            cmbb.ItemsSource = inp;
            cmbb.SelectedIndex = 0;
         }
   }


here i want to make that textbox should contain value from 0 to 500 and there should be vertical scorlling in the textbox

its an wpf application
Posted
Updated 5-Nov-13 1:50am
v2
Comments
CPallini 5-Nov-13 8:05am    
Why don't you use a ListBox?

Then append the values rather than assign them. Either:
C#
textbox.Text += inp.ToString();
or better, use a StringBuilder:
C#
StringBuilder sb = new StringBuilder;
string sep = "";
for (int i = 0; i <= ymax; i++)
   {
      inp.Add(i);
      sb.AppendFormat("{0}{1}", sep, inp);
      sep = ",";
      cmbb.ItemsSource = inp;
      cmbb.SelectedIndex = 0;
   }
textbox.Text = sb.ToString();
But... you probably want to move the cmbb lines outside the loop as well.
 
Share this answer
 
C#
Collapse | Copy Code

private void Window_Loaded_1(object sender, RoutedEventArgs e)
   {
      int ymax = 500;
      parentchart.Axes.Add(new LinearAxis() { Minimum = 0, Orientation=AxisOrientation.Y, Maximum = ymax > 0 ? ymax : 300 });
      txty.Text = ymax.ToString();
      List<int> inp = new List<int>();
      for (int i = 0; i <= ymax; i++)
         {
            inp.Add(i);
            textbox.Text = inp.ToString();
            cmbb.ItemsSource = inp;
            cmbb.SelectedIndex = 0;
         }
   }

textbox.Text += inp.ToString();



StringBuilder sb = new StringBuilder;
string sep = "";
for (int i = 0; i <= ymax; i++)
{
inp.Add(i);
sb.AppendFormat("{0}{1}", sep, inp);
sep = ",";
cmbb.ItemsSource = inp;
cmbb.SelectedIndex = 0;
}
textbox.Text = sb.ToString();
 
Share this answer
 

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