<?xml version="1.0" encoding="utf-16"?><customize><COR_CUSTOM_FIELD U_RuleName="DOC_10162: Search Item in document rows" U_Type="0" U_Action="" U_Warning=" " U_WarningText="" U_WarningBox=" " U_WarningStatus=" " U_Active="Y" U_FormTypeBasis="" U_ItemUIDBasis="" U_ColumnBasis="" U_FormType="149,139,131,133,141,142,181,60092,65301,65309,182" U_ItemUID="" U_Column="" U_EventType="16" U_Before=" " U_Mode="-1" U_Refresh=" " U_EasyFunctionRule="" U_Creator="" U_LastModified="24.07.2012 17:56:53" U_LastModifiedBy="1" U_Permission="" U_ErrorBox=" " U_ErrorStatus=" "><U_Expression>/****** General Information *****Creator: coresystems ag, muf@coresystems.chCreate Date: 2012-07-24***** StartConfDesc *****Create a Label, Text box and Search button on a document form and search all rows for the value entered. Highlight the row if found.Useful when creating documents with many rows and having to adjust a row with a certain item, for example when the quantity falls below zero***** EndConfDesc ********** Updates *****2012-07-24, muf: Initial Rule*/string ruleName = pVal.RuleInfo.RuleName.ToString();string errorMessage = "Error in Optimizer Rule '" + ruleName + "'";// Matrix and column to searchstring matrixUID = "38";// Here Itemstring colUID = "1";// Define the reference item where to position the new lable, textbox and search button// Here the currency on the Marketing document form headerstring refUID = "15";string lableValue = "Item No.: ";string buttonValue = "Search";string nameSpace = "COR_";string msgError = "Cannot search in documents rows of type Service. Change to Item Type.";try{	// Use a reference item to set the size and position of the new items	Item refItem = Item.GetFromUID(pVal.Form, refUID); 	// Lable	Label l = Label.CreateNew(nameSpace + "L1");	l.SetSizeAndPosition(refItem);	l.Top = l.Top + 40;	l.Value = lableValue;	// Text box to enter value to search for	TextEdit t = TextEdit.CreateNew(nameSpace + "T1");	t.SetSizeAndPosition(l);	t.Left = l.Left + l.Width + 15;	// Search Button	Button b = Button.CreateNew(nameSpace + "B1");	b.Value = buttonValue;	b.SetSizeAndPosition(t);	b.Left = t.Left + t.Width + 15;	// Add the new items ...	pVal.Form.AddItem(l);	pVal.Form.AddItem(t);	pVal.Form.AddItem(b);	// ...and update the form	pVal.Form.Update();	// Now add a delegate to react when the user selects the search button	SwissAddonFramework.UI.EventHandling.ItemEvents.ItemPressedEventHandler ev = null;	ev = delegate (SwissAddonFramework.UI.EventHandling.ItemEvents.ItemPressed e)		{		try 		{			// Check the document type since the search only works for items			string docType = ComboBox.GetFromUID(pVal.Form, "3").Value;			if (docType == "S")			{				StatusBar.WriteError(msgError);				return;			}			// If the Document is of Item Type get the matrix...			Matrix m = Matrix.GetFromUID(pVal.Form, matrixUID);			// ... and search in the rows			for (int index = 0; index &lt; m.Rows.Count; index++)			{				string mItem = m.GetValue(colUID, index);				if (mItem == t.Value)				{					// find the first row with the item entered					m.Columns["0"].Cells[index].Click(SwissAddonFramework.UI.Components.MatrixColumn.ClickTypes.Regular, SwissAddonFramework.UI.Components.MatrixColumn.Modifier.None);					break;				}			}		}		catch (Exception ex)		{			StatusBar.WriteError(errorMessage + ": " + ex.Message);		}		};			b.AddHandler_ItemPressed(SwissAddonFramework.UI.Components.ModeComponent.FormModes.ALL, null, ev);}catch(System.Exception ex){	//MessageBox.Show(errorMessage + ": \n" + ex.Message, "OK");	StatusBar.WriteError(errorMessage + ": " + ex.Message);	Debug.WriteMessage(errorMessage + ": " + ex.Message, Debug.DebugLevel.Exception);}return true;</U_Expression></COR_CUSTOM_FIELD></customize>