Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Updating Form's lable from external Class , not working !!!

Updating Form's lable from external Class , not working !!!

Scheduled Pinned Locked Moved C#
questionannouncement
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zinc_z
    wrote on last edited by
    #1

    I have control Lable on Form , I wanted to update text propertrty of that control from another class in same namepsace so I expose that label control visa public property . and now I m using that property in my other class for setting text fro that lable .. but the new text is not displaying on Form ??? What I am doing wrong here ??? Class Form1 { public string updatelable { get { return label.text ; } set { label.Text = (string)value; } and using it in my other class as Form1 f = new Form1(); f.updatelable = "abc"; but its not working... what I m doing wrong here ??? Thanks

    HELLO

    M N 2 Replies Last reply
    0
    • Z zinc_z

      I have control Lable on Form , I wanted to update text propertrty of that control from another class in same namepsace so I expose that label control visa public property . and now I m using that property in my other class for setting text fro that lable .. but the new text is not displaying on Form ??? What I am doing wrong here ??? Class Form1 { public string updatelable { get { return label.text ; } set { label.Text = (string)value; } and using it in my other class as Form1 f = new Form1(); f.updatelable = "abc"; but its not working... what I m doing wrong here ??? Thanks

      HELLO

      M Offline
      M Offline
      Martin 0
      wrote on last edited by
      #2

      Hello, You have to add "this.Refresh()" in the set of your property. All the best, Martin

      1 Reply Last reply
      0
      • Z zinc_z

        I have control Lable on Form , I wanted to update text propertrty of that control from another class in same namepsace so I expose that label control visa public property . and now I m using that property in my other class for setting text fro that lable .. but the new text is not displaying on Form ??? What I am doing wrong here ??? Class Form1 { public string updatelable { get { return label.text ; } set { label.Text = (string)value; } and using it in my other class as Form1 f = new Form1(); f.updatelable = "abc"; but its not working... what I m doing wrong here ??? Thanks

        HELLO

        N Offline
        N Offline
        Not Active
        wrote on last edited by
        #3

        You can only update the control in the UI thread. You'll need to use invoke, or some other method to update the text on the label.


        only two letters away from being an asset

        Z 1 Reply Last reply
        0
        • N Not Active

          You can only update the control in the UI thread. You'll need to use invoke, or some other method to update the text on the label.


          only two letters away from being an asset

          Z Offline
          Z Offline
          zinc_z
          wrote on last edited by
          #4

          I am using Asynchronous methods in my extern class and trying to update UI from these methods . I have created a delegate and delegate method in Form1 class and when I tried to invoke delegate from external class it says definition of invoke does't exist in current reference ... ??? What I m doing wrong here ? Thanks

          M 1 Reply Last reply
          0
          • Z zinc_z

            I am using Asynchronous methods in my extern class and trying to update UI from these methods . I have created a delegate and delegate method in Form1 class and when I tried to invoke delegate from external class it says definition of invoke does't exist in current reference ... ??? What I m doing wrong here ? Thanks

            M Offline
            M Offline
            Martin 0
            wrote on last edited by
            #5

            Hello, For helping you we hav to know a little more. Please show us the code of: delegate, invoke call and method;

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups