Hi,
I'm trying to make a Form that will contain a TextBox into which I can write a value. All of this would be fine, but I have a problem with entering a value in the TextBox that does not appear in the List, the previous value would return to the TextBox.
What I have tried:
private void elementTextBox_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
var elementString = elementTextBox.Text;
elementTextBox_PreviewKeyDown(sender, e, elementString);
}
private async void elementTextBox_PreviewKeyDown(object sender, KeyEventArgs e,string element)
{
var myListOids = selectedOIDs.ToList();
var myListOfElement = listOfElementNumber.ToList();
DictionaryObjectId(myListOids, myListOfElement);
var scaleString = scaleTextBox.Text;
var scale = Int32.Parse(scaleString);
var elementString = elementTextBox.Text;
if (e.Key == Key.Return)
{
if (myListOfElement.Contains(elementString))
{
var oidByElement = dictionaryOid.FirstOrDefault(pair => pair.Key == elementString).Value;
objectIdTextBox.Text = oidByElement.ToString();
await ScaleTask(scale, oidByElement);
}
else
{
MessageBox.Show("Inadequate value!");
elementTextBox.Text = element;
}
}
}
I have no idea how to pass that value, I thought (as it is in the code) that it could work when clicking into the field that it would take the value, but I don't know how to pass other values to the method elementTextBox_PreviewKeyDown (object sender, KeyEventArgs e, string element )
I will be happy for any advice or idea.
David