Guest User

Untitled

a guest
Jul 13th, 2014
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.42 KB | None | 0 0
  1. namespace Class1
  2. {
  3.     public partial class MainWindow : Window
  4.     {
  5.         public TextBox getBox() { return this.textbox1; }//1. не работает
  6.  
  7.     public string TextBoxText   // 2. тоже не работает.
  8.         {
  9.             set { TAlert.Text = value; }
  10.             get { return TAlert.Text; }
  11.         }
  12.  
  13.         public MainWindow()
  14.         {
  15.             InitializeComponent();
  16.         }
  17.  
  18.         public void Button_Click_1(object sender, RoutedEventArgs e)
  19.         {
  20.             Class2 a= new Class2(this);
  21.         }
  22.     }
  23. }
  24. ------------------------------------------------------------------------------------------
  25. using System;
  26. using System.Collections.Generic;
  27. using System.Linq;
  28. using System.Text;
  29. using System.Threading.Tasks;
  30.  
  31. namespace Class1
  32. {
  33.     class Class2
  34.     {
  35.         public MainWindow wnd;
  36.         public System.Windows.Controls.TextBox t;
  37.  
  38.         Timer timer = new Timer(3000);
  39.  
  40.         public Class2(MainWindow win)
  41.         {
  42.         wnd = win;
  43.             t = wnd.getBox();
  44.             timer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
  45.             timer.Enabled = true;
  46.         }
  47.         public void OnTimedEvent(object sender, ElapsedEventArgs e)
  48.         {
  49.             System.Windows.Controls.TextBox t = MainWindow.getBox();
  50.             t.Text +="Тут строки\n";
  51.             wnd.TextBoxText += "Тут тоже не работает \n";
  52.         }
  53.  
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment