/// <summary> /// Removes any 'Joker' characters from a Criteria TextBox /// </summary> /// <param name="AFindCriteriaDataTable"></param> /// <param name="ASplitButton"></param> /// <param name="AAssociatedTextBox"></param> /// <param name="ALastSelection"></param> public static void RemoveJokersFromTextBox(DataTable AFindCriteriaDataTable, SplitButton ASplitButton, TextBox AAssociatedTextBox, TMatches ALastSelection) { string NewText; try { if (AAssociatedTextBox != null) { // Remove * Joker character(s) NewText = AAssociatedTextBox.Text.Replace("*", String.Empty); // If an EXACT search is wanted, we need to remove the % Joker character(s) as well if (ALastSelection == TMatches.EXACT) { NewText = NewText.Replace("%", String.Empty); } // TLogging.Log( // "RemoveJokersFromTextBox: Associated TextBox's (" + AAssociatedTextBox.Name + ") Text (1): " + AAssociatedTextBox.Text); // AFindCriteriaDataTable.Rows[0].BeginEdit(); // AAssociatedTextBox.Text = NewText; // AFindCriteriaDataTable.Rows[0].EndEdit(); string fieldname = ((TextBox)AAssociatedTextBox).DataBindings[0].BindingMemberInfo.BindingMember; AFindCriteriaDataTable.Rows[0][fieldname] = NewText; fieldname = ((SplitButton)ASplitButton).DataBindings[0].BindingMemberInfo.BindingMember; AFindCriteriaDataTable.Rows[0][fieldname] = Enum.GetName(typeof(TMatches), ALastSelection); // AFindCriteriaDataTable.Rows[0].EndEdit(); // // AAssociatedTextBox.Text = NewText; // // TLogging.Log( // "RemoveJokersFromTextBox: Associated TextBox's (" + AAssociatedTextBox.Name + ") Text (2): " + AAssociatedTextBox.Text); } } catch (Exception exp) { MessageBox.Show("Exception in RemoveJokersFromTextBox: " + exp.ToString()); } }
private void RemoveJokersFromTextBox(SplitButton ASplitButton, TextBox AAssociatedTextBox, TMatches ALastSelection) { string NewText; try { if (AAssociatedTextBox != null) { // Remove * Joker character(s) NewText = AAssociatedTextBox.Text.Replace("*", String.Empty); // If an EXACT search is wanted, we need to remove the % Joker character(s) as well if (ALastSelection == TMatches.EXACT) { NewText = NewText.Replace("%", String.Empty); } // TLogging.Log( // "RemoveJokersFromTextBox: Associated TextBox's (" + AAssociatedTextBox.Name + ") Text (1): " + AAssociatedTextBox.Text); // FFindCriteriaDataTable.Rows[0].BeginEdit(); // AAssociatedTextBox.Text = AAssociatedTextBox.Text.Replace("*", String.Empty); // FFindCriteriaDataTable.Rows[0].EndEdit(); string fieldname = ((TextBox)AAssociatedTextBox).DataBindings[0].BindingMemberInfo.BindingMember; FFindCriteriaDataTable.Rows[0][fieldname] = NewText; fieldname = ((SplitButton)ASplitButton).DataBindings[0].BindingMemberInfo.BindingMember; FFindCriteriaDataTable.Rows[0][fieldname] = Enum.GetName(typeof(TMatches), ALastSelection); // // AAssociatedTextBox.Text = NewText; // // TLogging.Log( // "RemoveJokersFromTextBox: Associated TextBox's (" + AAssociatedTextBox.Name + ") Text (2): " + AAssociatedTextBox.Text); } } catch (Exception exp) { MessageBox.Show("Exception in RemoveJokersFromTextBox: " + exp.ToString()); } }
private void PutNewMatchValueIntoFindCriteriaDT(SplitButton ACriteriaControl, TMatches NewMatchValue, TextBox ATextBox, string ATextBoxText) { FFindCriteriaDataTable.Rows[0].BeginEdit(); ACriteriaControl.SelectedValue = Enum.GetName(typeof(TMatches), NewMatchValue); FFindCriteriaDataTable.Rows[0].EndEdit(); //TODO: It seems databinding is broken on this control // this needs to happen in the SplitButton control really string fieldname = ((SplitButton)ACriteriaControl).DataBindings[0].BindingMemberInfo.BindingMember; FFindCriteriaDataTable.Rows[0][fieldname] = Enum.GetName(typeof(TMatches), NewMatchValue); //TODO: DataBinding is really doing strange things here; we have to //assign the just entered Text again, otherwise it is lost!!! ATextBox.Text = ATextBoxText; }
/// <summary> /// Leave Handler for a Critera TextBox Control. /// </summary> /// <param name="AFindCriteriaDataTable"></param> /// <param name="ATextBox"></param> /// <param name="ACriteriaControl"></param> public static void CriteriaTextBoxLeaveHandler(DataTable AFindCriteriaDataTable, TextBox ATextBox, SplitButton ACriteriaControl) { TMatches NewMatchValue = TMatches.BEGINS; string TextBoxText = ATextBox.Text; string CriteriaValue; // TLogging.Log("GeneralLeaveHandler for " + ATextBox.Name + ". SplitButton: " + ACriteriaControl.Name); if (TextBoxText.Contains("*") || (TextBoxText.Contains("%")) || (TextBoxText.EndsWith("||"))) { if (TextBoxText.EndsWith("||") && !(TextBoxText.StartsWith("||"))) { // TLogging.Log(ATextBox.Name + " ends with || = ENDS"); NewMatchValue = TMatches.ENDS; } else if (TextBoxText.EndsWith("||") && (TextBoxText.StartsWith("||"))) { // TLogging.Log(ATextBox.Name + " begins with || and ends with || = EXACT"); NewMatchValue = TMatches.EXACT; } else if (TextBoxText.EndsWith("*") && !(TextBoxText.StartsWith("*"))) { // TLogging.Log(ATextBox.Name + " ends with * = BEGINS"); NewMatchValue = TMatches.BEGINS; } else if ((TextBoxText.EndsWith("*") && (TextBoxText.StartsWith("*"))) || (TextBoxText.StartsWith("*"))) { // TLogging.Log(ATextBox.Name + " begins and ends with *, or begins with * = CONTAINS"); NewMatchValue = TMatches.CONTAINS; } /* * See what the Criteria Value would be without any 'joker' characters * ( * and % ). */ CriteriaValue = TextBoxText.Replace("*", String.Empty); CriteriaValue = CriteriaValue.Replace("%", String.Empty); if (CriteriaValue != String.Empty) { // There is still a valid CriteriaValue PutNewMatchValueIntoFindCriteriaDT(AFindCriteriaDataTable, ACriteriaControl, NewMatchValue, ATextBox, TextBoxText); } else { // No valid Criteria Value, therefore empty the TextBox's Text. ATextBox.Text = String.Empty; } } else { // Ensure that 'BEGINS' is restored in case the user used the '*' joker before but // has cleared it now! PutNewMatchValueIntoFindCriteriaDT(AFindCriteriaDataTable, ACriteriaControl, NewMatchValue, ATextBox, TextBoxText); } }
private static void PutNewMatchValueIntoFindCriteriaDT(DataTable AFindCriteriaDataTable, SplitButton ACriteriaControl, TMatches NewMatchValue, TextBox ATextBox, string ATextBoxText) { AFindCriteriaDataTable.Rows[0].BeginEdit(); ACriteriaControl.SelectedValue = Enum.GetName(typeof(TMatches), NewMatchValue); AFindCriteriaDataTable.Rows[0].EndEdit(); //TODO: It seems databinding is broken on this control // this needs to happen in the SplitButton control really string fieldname = ((SplitButton)ACriteriaControl).DataBindings[0].BindingMemberInfo.BindingMember; AFindCriteriaDataTable.Rows[0][fieldname] = Enum.GetName(typeof(TMatches), NewMatchValue); //TODO: DataBinding is really doing strange things here; we have to //assign the just entered Text again, otherwise it is lost!!! ATextBox.Text = ATextBoxText; }