I have a form with label, textbox, and button.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WindowsFormsApplication
{
//add class to windows project
class ModelName
{
//declare variables
public string _name;
private string _modelName;
// add constructor and set _name variable to "enter model brand"
public ModelName()
{
_name = "Enter Model Brand";
}
//property called modelName- string type
public string modelName
{
get
{
return _modelName;
}
set
{
_modeName = "Martin";
}
}
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 WindowsFormsApplication2
{
public partial class Form1 : Form
{
ModelName myClass = new ModelName();
public Form1()
{
InitializeComponent();
}
// label has text 'enter brand name' when form loads
private void Form1_Load(object sender, EventArgs e)
{
label1.Text = myClass._name;
}
private void label1_Click(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
// ****NOT WORKING***** want martin to display
textBox1.Text = myClass.modelName
}
}
}
I want to click on button in form and have MARTIN display in textbox.
thank you
This post has been edited by gotagoJOE: 14 June 2009 - 05:49 AM

New Topic/Question
Reply




MultiQuote




|