Windows Develop Bookmark and Share   
 index > Windows Forms General > Change Label Text
 

Change Label Text

Hi,

I have a updatelabel.cs class

I want to use it to update label text property on a separate Windows Form.

How do I do this?

Thanks.

obrienkev  Monday, January 28, 2008 5:27 PM
Create a public property on your form of type string, which creates a separate private string variable to store the actual string data. Now, instead of using that private string variable for your property, use the LabelBox.Text property instead.

Code Snippet

public string LabelText1

{

get

{

return label1.Text;

}

set

{

label1.Text = value;

}

}

Rudedog

Rudedog2  Monday, January 28, 2008 5:38 PM
Create a public property on your form of type string, which creates a separate private string variable to store the actual string data. Now, instead of using that private string variable for your property, use the LabelBox.Text property instead.

Code Snippet

public string LabelText1

{

get

{

return label1.Text;

}

set

{

label1.Text = value;

}

}

Rudedog

Rudedog2  Monday, January 28, 2008 5:38 PM

where do I declare value??

and should the public property be in the form or the class file?

thanks.

obrienkev  Tuesday, January 29, 2008 9:31 AM

Declare that property on your Form. You do not need to declare value because it is a contextualkeyword. You must be using 2008. Take a look at how property members are declared and how they are used.

Rudedog

Rudedog2  Tuesday, January 29, 2008 2:08 PM

You can use google to search for other answers

Custom Search

More Threads

• Creating helper apps
• prevent focus steal
• windows 2000 loses copy paste option while uninstalling my .net application
• UrlEncode
• how to get name of all colors
• Use multiple usercontrols with one variable
• New winform projects C# (or VB2005) wont run/load/debug from IDE after upgrading computer hardware - help
• How to make Popup form on the top????
• Replace Prompt
• DateTimePicker - ValueChanged and TextChanged update issue