C# WinForms edit controls from another class.

10/08/2012 23:29 badguy4you#1
Please help me i can't use txtBox from the other classes.
10/09/2012 00:05 Kraizy​#2
PHP Code:
//call
txtbox.text myclass.bla();

//some other class
public class myclass
{
public static 
string bla()
{
return 
"bla";
}

sry i'm currently on my mobile phone..
10/09/2012 00:14 badguy4you#3
Quote:
Originally Posted by Kraizy​ View Post
PHP Code:
//call
txtbox.text bla();

//some other class
public class myclass
{
public static 
string bla()
{
return 
"bla";
}

sry i'm currently on my mobile phone..
I will need more clear answer when you get to your PC please because i can't understand what you posted. And thanks a lot for your help
10/11/2012 09:14 fatalaty#4
For a better understanding and a better help please post some code.
10/16/2012 09:59 Naworia#5
Quote:
Originally Posted by badguy4you View Post
I will need more clear answer when you get to your PC please because i can't understand what you posted. And thanks a lot for your help
Put some code or screenshot. Do you mean class file or classes?
10/18/2012 17:21 5anku#6
What you need is a property on the Label

Code:
namespace LabelTest
{
    public partial class TestForm : Form
    {
        // get and set method for Label.Text
        public string _Label
        {
            get
            {
                // Return Label.Text
                return Label.Text;
            }
            set
            {
                // Set Label.Text with value
                Label.Text = value;
            }
        }
        
        public TestForm()
        {
            InitializeComponent();
        }
    }
Code:
    class OtherClass
    {
        public void ChangeLabel()
        {
            // String with Text for Label
            string setThisText = "Bla";
            // Empty string
            string getThisText;
            
            // Attribute of Form
            TestForm Test = new TestForm();
            // Set method
            Test._Label = setThisText;
            // Get method (getThisText is now "Bla"
            getThisText = Test._Label;
        }
    }
}