hi:
When the TextBox the focus changes, how to switch the display Text?
The following is my code, how do I do?
When the focus changes textBox1, and not re-call GetText.
CustomTextBox.cs
using System;
using System.Data;
using Gizmox.WebGUI.Forms;
namespace TestWebGuiTextBoxFocus
{
public class CustomTextBox : TextBox
{
public override string Text
{
get
{
return base.Text;
}
set
{
if (base.Focused)
string.Format("Test [{0}] ", base.Text);
else
base.Text = value;
}
}
}
}
Form1.cs
#region Using
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using Gizmox.WebGUI.Common;
using Gizmox.WebGUI.Forms;
#endregion
namespace TestWebGuiTextBoxFocus
{
public partial class Form1 : Form
{
private CustomTextBox textBox1;
private Gizmox.WebGUI.Forms.TextBox textBox2;
public Form1()
{
InitializeComponent();
}
private void textBox1_GotFocus(object sender, EventArgs e)
{
base.Update();
}
private void textBox1_LostFocus(object sender, EventArgs e)
{
base.Update();
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.textBox1 = new TestWebGuiTextBoxFocus.CustomTextBox();
this.textBox2 = new Gizmox.WebGUI.Forms.TextBox();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(63, 47);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 21);
this.textBox1.TabIndex = 0;
this.textBox1.Text = "Value";
this.textBox1.LostFocus += new System.EventHandler(this.textBox1_LostFocus);
this.textBox1.GotFocus += new System.EventHandler(this.textBox1_GotFocus);
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(63, 88);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(100, 21);
this.textBox2.TabIndex = 1;
//
// Form1
//
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Size = new System.Drawing.Size(600, 301);
this.Text = "Form1";
this.ResumeLayout(false);
}
}
}