How to fill textbox from another Window? RRS feed

  • Question

  • Hi all,

    I know how to pass a value from one to another window/page. But how to fill a textbox, which is in SomePage from AnotherWindow ..... I tried this ... 

    function in SomeWindow
    SomePage sp = new SomePage();
    sp.txtName.Text = "some text";

    ... but without success

    In this way I know how to run function ... sp.some_function(); but no to fill a textBox

    thanks for answers

    Friday, July 24, 2020 8:04 AM

All replies

  • So new info:

    I run a function of Page1 from Window1 ... 

    public void read_data()
        txtCar_color.Text = "white";

    And MessageBox showed ... "white" ... but that text didnt show in textBox ... 

    why? how to fix this?

    Friday, July 24, 2020 8:55 AM
  • Hi,

    are you using the MVVM pattern, is there any binding on the page which prevent you from assigning the textbox text value.

    Best Regards,


    Friday, July 24, 2020 9:40 AM
  • This forum is for C# specific questions. Your question seems to be related to using a particular UI framework. What UI framework are you using (Winforms, WPF, ASP.NET, etc)?

    Also you're using terminology that has different meaning to different people. A page could be a web page or a XAML page. Window could be a Form or Window in Winforms/WPF or it could be a different app altogether. Please clarify if you're trying to set text from one "window" in your app to another "window" in your same app or if you're trying to do this across processes. Across processes require OS calls and cannot be done directly in .NET.

    Michael Taylor http://www.michaeltaylorp3.net

    Friday, July 24, 2020 1:32 PM
  • Hi

    In this SomePage define a function with string parameter
    public settext(string txt)
    txtName.Text = txt;
    In form1 call the function
    SomePage sp = new SomePage();
    sp.settext("some text");

    Thanks and regards

    Friday, July 24, 2020 6:54 PM
  • which kind of forms? webforms, winforms, wpf page/window? 
    Friday, July 24, 2020 8:17 PM