I'm trying to write a Enter Event for TB1 (textbox)
This code for Form1 (in Form1.cs) , would normally write it with the help of Designer:
using System;
using System.Windows.Forms;
namespace Project1
{
// aqui seria o método para o evento Enter que eu queria, o que está abaixo representado
// para que a letra 'text' desapareça
private void TB1_Enter(object sender, EventArgs e)
{
if(TB1.Text=="Text")
{
TB1.Text="";
}
}
}
In the code below I wanted to implement the above event. What I was going to want to know is if I could write the event in the below file so that it can be compiled later. >
using System;
using.System.Windows.Forms;
using System.Runtime.InteropServices;
namespace Project1
{
[ComVisible(true)]
public class EventArgs
{
//
//Summary:
//provides a value to use with events that do not have event data
public static readonly EventArgs Empty;
//
//Summary:
//Initializes a new instance of the System.EventArgs class
public EventArgs()
{
}
}
public class Form1:Form
{
public static void Main()
{
AplicationEnableVisualStyles();
Aplication.Run(new Form1());
}
public Form1()
{
//textBox1
TextBox TB1 = new TextBox();
TB1.Location = new Point(30, 20);
TB1.Size = new Size(100, 30);
TB1.Text = "Text";
//add control to textBox
this.Controls.Add(TB1);
}
}
}