I have this UITextField
named txtType that I need to know when it’s value changes and what the new value is. My code:
txtType.TextColor = UIColor.Blue;
txtType.TextAlignment = UITextAlignment.Center;
txtTyle.text = "Select Type";
txtType.Ended += new EventHandler(TextValue_Changed);
The TextValue_Changed
event:
private void TextValue_Changed(object sender, EventArgs e)
{
UITextField MyTextField = (UITextField)sender;
if (MyTextField.Text == "Different Type")
{
txtNumber.Text = "Some value";
}
else
{
txtNumber.Text = "Some other value";
}
}
The TextValue_Changed
function is executed, but the text value is still “Select Type”.
So I tried:
txtType.ValueChanged += new EventHandler(TextValue_Changed);
But same result, the TextValue_Changed
function is executed, but the text value is still “Select Type”.
And then I tried:
public partial class MyViewController: UIViewController, IUITextFieldDelegate
.
.
.Irrelevant code
.
.
txtType.Delegate = this;
[Foundation.Export("textFieldDidEndEditing:")]
public void EditingEnded(UITextField textField)
{
if (textField.Text == "Different Type")
{
txtNumber.Text = "Some value";
}
else
{
txtNumber.Text = "Some other value";
}
}
Once again, the function is executed but again the text is “Select Type”. I can’t seem to get the new value. What am I doing wrong?