Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Leave textbox 1

Status
Not open for further replies.

plsh

Programmer
Mar 5, 2003
118
ZA
Hi there,
I have a text box that when the user leaves I want to then populate a list box. At present I have the code workingperfectly on a button, but would prefer to have it fire as soon as the user leaves a text box. No matter what I do I can't get the event to work, it just ignores it all together.

Please I am going nuts.
 
what event do you use currently?

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
I am using the leave event, but I am not sure if the coding is corrent, do you possibly have an example?
 
post the code please.

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 

private void txtUniqueCode_Leave(object sender, System.EventArgs e)
{
int i=1;
while (i < lsPhase.Items.Count)
{
if (lsPhase.Items.ToString() == lsPhase.Items[i-1].ToString()) lsPhase.Items.RemoveAt(i);
else i++;
}
}

private void InitializeComponent()
{
this.txtUniqueCode.TextChanged += new System.EventHandler(this.txtUniqueCode_Leave);
}


I believe that in the InitializeComponent section it should rather read:
this.txtUniqueCode.Leave += new System.EventHandler(this.txtUniqueCode_Leave);

or something like that but there is no option for Leave.

Sorry I am new to c#
 
it exists... and it works. unless you're developping a web app...

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
Sorry, I am developing a c# .NET web application, any idea how I can do what I want in .NET
 
set the autopostback property of the textbox to true

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
Thanks I have now set that property. Should the rest of my code be correct? Or is there something else that needs to be changed?
 
you should move your code in the event that is generated by VS on double clicking the textbox (textchanged)

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
Thank you very much DaZZled, it worked like a charm
 
you're welcome

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top