none
How to Update or refresh label value form 2 from form 1 without close form2 or open form2

    Question

  • How to Update or  refresh label value form 2 from form 1 without close form2 or open form2. please help me
    • Moved by CoolDadTx Wednesday, April 10, 2019 1:59 PM Winforms related
    Tuesday, April 9, 2019 9:52 AM

All replies

  • It really depends on if we are talking about data where perhaps the label on Form2 has Bindings set e.g. DataBindings.Add, otherwise you change the modifier property of the label from private to public which then allow you to access/change the label value without closing and opening the form again. 

    There are other ways too but would be great if you could provide more details rather than a very generic question.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, April 9, 2019 12:42 PM
    Moderator
  • Hi,

    Any update here?

    Regards,

    Kyle


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, April 18, 2019 6:57 AM
    Moderator
  • Hi zeref_arie,

    I recommend using Interfaces for this kind of functionality. Depending on what you're doing, it maybe "overkill", but generally speaking it's the best way to go about doing this. If you start out just accessing public properties on another form, you end up tightly-coupling the two forms ... and if you find that you need to extend that functionality to other forms, you'd end up with a lot more work or rewriting everything.

    See my blog post (https://geek-goddess-bonnie.blogspot.com/2010/06/program-to-interface.html) and hopefully it will give you some ideas for your situation.

    I also have two other blog posts about passing data between forms (the 3rd option in the first post below makes use of Interfaces as well ... pretty much like in my blog post above):

    http://geek-goddess-bonnie.blogspot.com/2011/01/passing-data-between-forms.html
    http://geek-goddess-bonnie.blogspot.com/2012/12/passing-data-between-forms-redux_31.html

    Hope this helps …  =0)


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    Sunday, April 21, 2019 12:13 AM