Textchanged has a bug ?

  • Thread starter Thread starter itroad
  • Start date Start date
I

itroad

Hi

Textbox's TextChanged event was fired when press Ctrl+A in it.
Is it bug or feature?

..net framework ver 3.5
IDE vs.net 2008 pro
 
Hi, itroad,

It doesn't happen to me in ver 2.0. Must be new in 2008.

Cheers,
Randy
 
Hi

sample code is here, it's very simple.

----------------------------------Program.cs--------------------------------------------------
using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
static class Program
{
/// <summary>
/// $B%"%W%j%1!<%7%g%s$N%a%$%s(B $B%(%s%H%j(B $B%]%$%s%H$G$9!#(B <------ japanese
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form2());
}
}
}

--------------------------------------Form2.Designer.cs------------------------------------------------------
namespace WindowsFormsApplication1
{
partial class Form2
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed;
otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <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 System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(44, 40);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(200, 19);
this.textBox1.TabIndex = 0;
this.textBox1.Text = "default value";
this.textBox1.TextChanged += new
System.EventHandler(this.textBox1_TextChanged);
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(44, 78);
this.textBox2.Multiline = true;
this.textBox2.Name = "textBox2";
this.textBox2.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.textBox2.Size = new System.Drawing.Size(200, 119);
this.textBox2.TabIndex = 1;
//
// Form2
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 263);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Name = "Form2";
this.Text = "Form2";
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
}
}

------------------------------------------Form2.cs----------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}

private void textBox1_TextChanged(object sender, EventArgs e)
{
textBox2.Text += textBox1.Text + "\r\n";
}
}
}

--------------------------------------End--------------------------------------------------------------
 
itroad,

It's pretty easy to reproduce. I'm using Vista Ultimate with VS 2008
Ver. 9.0.30728.1SP with framework 3.5 SP1 and get the same behaviour.

What os are you using? The reason I ask is because I've had a similar
feature/bug with labels. Put a label on a form and dbl click it
during execution. On a Vista box the text is copied to the clipboard
whereas on an XP box it doesn't. I posted on the MSDN site and they
replied (pretty quickly) with code to create a custom label to stop
the behaviour but they weren't sure why it happening in the first
place.

Thanks for posting. Anyone got Win7 with vs 2010 beta to try?

SMJT
 
SMJT.

My env is

IDE:
Microsoft Visual Studio 2008
Version 9.0.21022.8 RTM
Microsoft .NET Framework
Version 3.5 SP1

OS:
Vista Business SP1
 
Back
Top