Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Something really odd - when the user changes the text in a combobox [cbClient] it launches the cbClient_TextChanged event at which point I want to evaluate the NEW value in cbClient to see if it matches a certain criteria.

Problem I am having (no clue why) is that when the event is handled the value of "CbClient.text" is still the OLD value and not the new updated value.

 

For example - currently in cbClient.Text = "Client1", if there user deletes/backspaces the "1" then the NEW value in cbClient should be = "Client" HOWEVER when (in the event) I do cbClient.Text it still gives me the OLD value "Client1".

Is there anyway to get the NEW value? Use a different event? Different command? Thanks...

Posted

Strange. I get the behavior you mentioned when the control is bound to a datasource, but not when I populate the Items collection manually:

 

private void comboBox1_TextChanged(object sender, System.EventArgs e)
{
   MessageBox.Show(this.comboBox1.Text);
}

private void Form1_Load(object sender, System.EventArgs e)
{
   this.comboBox1.Items.AddRange(new string[] {"Item 1","Item 2","Item 3","Item 4"});
}

Here's what I'm up to.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...