Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi
I am using 2 fields
company name
Abbrevation

when I am enter the company name, starting 3 character
from company textbox will automatically or simultaneously appear in Abbrevation textbox.

pleasesolve it
Posted
Comments
Dylan Morley 6-Jan-12 5:35am    
Is this in ASP.Net or Winforms?
Sergey Alexandrovich Kryukov 6-Jan-12 5:39am    
All you need is reading of one short MSDN page on TextBox. I don't know what exactly TextBox type do you mean -- there are more than one, so please find it yourself -- this is one click away.
--SA

Assuming Winforms, handle the TextBox.TextChanged event:
C#
private void myTextBox_TextChanged(object sender, EventArgs e)
    {
    if (!string.IsNullOrEmpty(myTextBox.Text))
        {
        myOtherTextBox.Text = myTextBox.Text.Substring(0, 3);
        }
    }
 
Share this answer
 
C#
private void TextBox1_KeyUp(object sender, KeyEventArgs e)//Select KeyUp from Event
        {
           if(TextBox2.Text.Length<3)
            Textbox2.Text=Textbox1.Text.ToUpper; 
        }
 
Share this answer
 
v3
<pre lang="c#">
private void txtcompanyname_TextChanged(object sender, EventArgs e)
{
if (txtcompanyname.Text.Length > 3)
{
txtAbbrevation.Text = txtcompanyname.Text;
}
}
</pre>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900