BAQ DataView, how to invoke row rules without clicking on the grid

HI

We have two BAQ dataviews binded to a grid, however when clicking the retrieve button you have to click the grid to see the rows highlighted. I have tried clicking grid only and not having it ticked when going though the Rule Wizard. Is there a way upon retrieval to automatically see the row highlighted?

Please see my code below

// Custom code for CustomerTrackerForm
// Created: 11/10/2017 14:00:32
// **************************************************

extern alias Erp_Contracts_BO_Company;
extern alias Erp_Contracts_BO_ARAgingTracker;


extern alias Erp_Contracts_BO_Customer;
extern alias Erp_Contracts_BO_CreditManager;
extern alias Erp_Contracts_BO_ARInvoice;
extern alias Erp_Contracts_BO_Quote;
extern alias Erp_Contracts_BO_CustCnt;
extern alias Erp_Contracts_BO_ARLOC;
extern alias Erp_Contracts_BO_CashDtlSearch;
extern alias Erp_Contracts_BO_ServiceContract;
extern alias Erp_Contracts_BO_CustShip;
extern alias Erp_Contracts_BO_CashRecSearch;
extern alias Erp_Contracts_BO_ARPromissoryNotes;
extern alias Erp_Contracts_BO_SalesOrdHedDtl;
extern alias Erp_Contracts_BO_OrderDtlSearch;
extern alias Erp_Contracts_BO_ShipDtlSearch;
extern alias Ice_Contracts_BO_DynamicQuery;

using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.Adapters;
using Erp.UI;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;
using Ice.Lib.Broadcast;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Reflection;
using Ice.BO;

public class Script
{
	/*
		Epacsys epac_sr 9 Sept 2021 Upgrade to Kinetic 2021.1.8. Tidied fields on Customer - Atributes tab
	*/
	// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
	// Begin Wizard Added Module Level Variables **
	private BAQDataView bdvCustomer;
	private BAQDataView bdvInvClosed;
	private DataView Customer_DataView;
	private EpiBaseAdapter oTrans_customerAdapter;
	// End Wizard Added Module Level Variables **

	// Add Custom Module Level Variables Here **
	
	

	public void InitializeCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
		// Begin Wizard Added Variable Initialization

		
		this.Customer_DataView = this.Customer_Row.dataView;
		this.oTrans_customerAdapter = ((EpiBaseAdapter)(this.csm.TransAdaptersHT["oTrans_customerAdapter"]));
		
this.Customer_DataView.ListChanged += new ListChangedEventHandler(this.Customer_DataView_ListChanged);
		// End Wizard Added Variable Initialization

		// Begin Wizard Added Custom Method Calls
		
		bdvCustomer = new BAQDataView("InvoiceHedCustTracker");
		oTrans.Add("InvoiceHedCustTrackerBAQ", bdvCustomer);

		bdvInvClosed= new BAQDataView("InvoiceHedCustTracker(closed)");
		oTrans.Add("InvoiceHedCustTrackerClosedBAQ", bdvInvClosed);
	
		
this.btnRun.Click += new System.EventHandler(this.btnRun_Click);
		
		CreateRowRuleInvoiceHedCustTrackerBAQHDCase2_HDCaseStatusContains_CLOSED();;
		CreateRowRuleInvoiceHedCustTrackerBAQHDCase2_HDCaseStatusContains_OPEN();;
		this.btnRtv.Click += new System.EventHandler(this.btnRtv_Click);
		CreateRowRuleInvoiceHedCustTrackerClosedBAQHDCase2_HDCaseStatusContains_OPEN();;
		CreateRowRuleInvoiceHedCustTrackerClosedBAQHDCase2_HDCaseStatusContains_CLOSED();;
		// End Wizard Added Custom Method Calls
	}

	public void DestroyCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
		// Begin Wizard Added Object Disposal

		bdvCustomer = null;
		bdvInvClosed = null;

		this.btnRun.Click -= new System.EventHandler(this.btnRun_Click);
		this.Customer_DataView = null;
		this.oTrans_customerAdapter = null;
		this.Customer_DataView.ListChanged -= new ListChangedEventHandler(this.Customer_DataView_ListChanged);
		this.btnRtv.Click -= new System.EventHandler(this.btnRtv_Click);
		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal



		// End Custom Code Disposal
	}

	private void CustomerTrackerForm_Load(object sender, EventArgs args)
	{
		// Add Event Handler Code
		EpiBasePanel detailPanel1;
		detailPanel1 = (EpiBasePanel)(csm.GetNativeControlReference("8fd5b1fa-db9e-423c-baca-4656696c859b"));
		detailPanel1.Focus();
	}


	private void btnRun_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
		InvoiceHedCustTrackerBAQ();

	}



	private void InvoiceHedCustTrackerBAQ()
	{
		
EpiUltraGrid grdOpenInv = (EpiUltraGrid)csm.GetNativeControlReference("35897ae0-bf81-4358-beaa-7b6b41599fa1");

		int CustNum = 0;
		if (Customer_Row.CurrentDataRow != null)
			CustNum = (int)Customer_Row.CurrentDataRow["CustNum"];
		string filter = "1 = 2";

		bdvCustomer.dataView.RowFilter = filter;
	

		using (DynamicQueryAdapter queryAdapter = new DynamicQueryAdapter(this.oTrans))
		{
			queryAdapter.BOConnect();
			QueryExecutionDataSet dsExecute = new QueryExecutionDataSet();

			dsExecute.ExecutionFilter.Clear();
			dsExecute.ExecutionParameter.Clear();
			dsExecute.ExecutionFilter.AddExecutionFilterRow("Customer", "CustNum", false, "=", CustNum.ToString(), Guid.Empty, null);

			queryAdapter.QueryResults.Tables["Results"].Clear();
			queryAdapter.ExecuteByID("InvoiceHedCustTracker", dsExecute);
			bdvCustomer.dataView.Table = queryAdapter.QueryResults.Tables["Results"].Copy();

			try //added
{
					// table named results has results
					grdOpenInv.DataSource = queryAdapter.QueryResults.Tables["Results"]; // vData is a pointer to my Grid
					grdOpenInv.EpiAutoFit = true; // not sure this works!
					// Cleanup Adapter Reference
					queryAdapter.Dispose();
				}
				catch (System.Exception ex)
				{
					MessageBox.Show(ex.ToString());
				}
			}  //ends
}
		



	private void InvoiceHedCustTrackerClosedBAQ()
	{
		EpiUltraGrid grdClosedInv = (EpiUltraGrid)csm.GetNativeControlReference("95743524-42ab-4dbd-ad74-e6e2b347abc6");

		int CustNum = 0;
		if (Customer_Row.CurrentDataRow != null)
			CustNum = (int)Customer_Row.CurrentDataRow["CustNum"];
		string filter = "1 = 2";

		bdvInvClosed.dataView.RowFilter = filter;
	

		using (DynamicQueryAdapter queryAdapter = new DynamicQueryAdapter(this.oTrans))
		{
			queryAdapter.BOConnect();
			QueryExecutionDataSet dsExecute = new QueryExecutionDataSet();

			dsExecute.ExecutionFilter.Clear();
			dsExecute.ExecutionParameter.Clear();
			dsExecute.ExecutionFilter.AddExecutionFilterRow("Customer", "CustNum", false, "=", CustNum.ToString(), Guid.Empty, null);

			queryAdapter.QueryResults.Tables["Results"].Clear();
			queryAdapter.ExecuteByID("InvoiceHedCustTracker(closed)", dsExecute);
			bdvInvClosed.dataView.Table = queryAdapter.QueryResults.Tables["Results"].Copy();

			try 
{
					// table named results has results
					grdClosedInv.DataSource = queryAdapter.QueryResults.Tables["Results"]; // vData is a pointer to my Grid
					grdClosedInv.EpiAutoFit = true; // not sure this works!
					// Cleanup Adapter Reference
					queryAdapter.Dispose();
				}
				catch (System.Exception ex)
				{
					MessageBox.Show(ex.ToString());
				}
}
}
			 

	private void CreateRowRuleInvoiceHedCustTrackerClosedBAQHDCase2_HDCaseStatusContains_CLOSED()
	{
		// Description: ClosedInvoicesClosedcase
		// **** begin autogenerated code ****
		ControlSettings myControlSettings = new ControlSettings();
		myControlSettings.BackColor = System.Drawing.Color.LightGreen;
		RuleAction errorInvoiceHedCustTrackerClosedBAQ_RowAction = RuleAction.AddRowSettings(this.oTrans, "InvoiceHedCustTrackerClosedBAQ", false, myControlSettings);
		RuleAction[] ruleActions = new RuleAction[] {
				errorInvoiceHedCustTrackerClosedBAQ_RowAction};
		// Create RowRule and add to the EpiDataView.
		RowRule rrCreateRowRuleInvoiceHedCustTrackerClosedBAQHDCase2_HDCaseStatusContains_CLOSED = new RowRule("InvoiceHedCustTrackerClosedBAQ.HDCase2_HDCaseStatus", RuleCondition.Contains, "CLOSED", ruleActions);
		((EpiDataView)(this.oTrans.EpiDataViews["InvoiceHedCustTrackerClosedBAQ"])).AddRowRule(rrCreateRowRuleInvoiceHedCustTrackerClosedBAQHDCase2_HDCaseStatusContains_CLOSED);
		// **** end autogenerated code ****
	}



	private void CreateRowRuleInvoiceHedCustTrackerClosedBAQHDCase2_HDCaseStatusContains_OPEN()
	{
		// Description: ClosedInvoiceOpencase
		// **** begin autogenerated code ****
		
		RuleAction errorInvoiceHedCustTrackerClosedBAQ_RowAction = RuleAction.AddRowSettings(this.oTrans, "InvoiceHedCustTrackerClosedBAQ", false, SettingStyle.Error);
		RuleAction[] ruleActions = new RuleAction[] {
				errorInvoiceHedCustTrackerClosedBAQ_RowAction};
		// Create RowRule and add to the EpiDataView.
		RowRule rrCreateRowRuleInvoiceHedCustTrackerClosedBAQHDCase2_HDCaseStatusContains_OPEN = new RowRule("InvoiceHedCustTrackerClosedBAQ.HDCase2_HDCaseStatus", RuleCondition.Contains, "OPEN", ruleActions);
		((EpiDataView)(this.oTrans.EpiDataViews["InvoiceHedCustTrackerClosedBAQ"])).AddRowRule(rrCreateRowRuleInvoiceHedCustTrackerClosedBAQHDCase2_HDCaseStatusContains_OPEN);
		// **** end autogenerated code ****
	}



	private void btnRtv_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **

		InvoiceHedCustTrackerClosedBAQ();
	}

			

	private void Customer_DataView_ListChanged(object sender, ListChangedEventArgs args)

	{

		// ** Argument Properties and Uses **
		// Customer_DataView[0]["FieldName"]
		// args.ListChangedType, args.NewIndex, args.OldIndex
		// ListChangedType.ItemAdded, ListChangedType.ItemChanged, ListChangedType.ItemDeleted, ListChangedType.ItemMoved, ListChangedType.Reset
		// Add Event Handler Code
		if (grdOpenInv.DataSource != null)
		((DataTable)grdOpenInv.DataSource).Clear();

		if (grdClosedInv.DataSource != null)
		((DataTable)grdClosedInv.DataSource).Clear();

	}
	


	private void CreateRowRuleInvoiceHedCustTrackerBAQHDCase2_HDCaseStatusContains_CLOSED()
	{
		// Description: Open Invoices
		// **** begin autogenerated code ****
		ControlSettings myControlSettings = new ControlSettings();
		myControlSettings.BackColor = System.Drawing.Color.LightGreen;
		RuleAction okInvoiceHedCustTrackerBAQ_RowAction = RuleAction.AddRowSettings(this.oTrans, "InvoiceHedCustTrackerBAQ", false, myControlSettings);
		RuleAction[] ruleActions = new RuleAction[] {
				okInvoiceHedCustTrackerBAQ_RowAction};
		// Create RowRule and add to the EpiDataView.
		RowRule rrCreateRowRuleInvoiceHedCustTrackerBAQHDCase2_HDCaseStatusContains_CLOSED = new RowRule("InvoiceHedCustTrackerBAQ.HDCase2_HDCaseStatus", RuleCondition.Contains, "CLOSED", ruleActions);
		((EpiDataView)(this.oTrans.EpiDataViews["InvoiceHedCustTrackerBAQ"])).AddRowRule(rrCreateRowRuleInvoiceHedCustTrackerBAQHDCase2_HDCaseStatusContains_CLOSED);
		// **** end autogenerated code ****
	}


	private void CreateRowRuleInvoiceHedCustTrackerBAQHDCase2_HDCaseStatusContains_OPEN()
	{
		// Description: Open Invoices OpenCase
		// **** begin autogenerated code ****
		RuleAction errorInvoiceHedCustTrackerBAQ_RowAction = RuleAction.AddRowSettings(this.oTrans, "InvoiceHedCustTrackerBAQ", false, SettingStyle.Error);
		RuleAction[] ruleActions = new RuleAction[] {
				errorInvoiceHedCustTrackerBAQ_RowAction};
		// Create RowRule and add to the EpiDataView.
		RowRule rrCreateRowRuleInvoiceHedCustTrackerBAQHDCase2_HDCaseStatusContains_OPEN = new RowRule("InvoiceHedCustTrackerBAQ.HDCase2_HDCaseStatus", RuleCondition.Contains, "OPEN", ruleActions);
		((EpiDataView)(this.oTrans.EpiDataViews["InvoiceHedCustTrackerBAQ"])).AddRowRule(rrCreateRowRuleInvoiceHedCustTrackerBAQHDCase2_HDCaseStatusContains_OPEN);
		// **** end autogenerated code ****
	}
	}```

Regards
Kirsty