ntahip

ntahip

  • NA
  • 3
  • 0

cannot set button properties from a different class.

Jan 4 2011 1:20 AM
What am I doing wrong.  Trying to make a button disappear from my player class hide method.  code to follow:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication4
{
    public partial class Form1 : Form
    {
        
        public Form1()
        {
            InitializeComponent();                        
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Player p1 = new Player();
            p1.Hide();           
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }
        public Boolean button1Visible
        {
            get { return this.button1.Visible; }
            set { this.button1.Visible = value; }
        }      
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;


namespace WindowsFormsApplication4
{
    class Player
    {        
        public void Hide()
        {
            Form1 frm1 = new Form1();
            frm1.button1Visible = true;
         }       
    }
}



Answers (3)