C# EpiUltraGrid Help

Hi

Hopefully simple query for somebody that knows…

private void grdLotNumbers_AfterRowActivate(object sender, System.EventArgs args)
{
      MessageBox.Show(args.CurrentView.dataView[args.CurrentRow]["PartLot_PartNum"].ToString());
}

I use the args.CurrentView.dataView etc line of code on a deployed dashboard, with the AfterRowChange method and it works lovely.

I added this method using the wizard, and I want to get data from one of the cells in the grid. It doesn’t compile with the above, reports this error:

Error: CS1061 - line 227 (546) - 'System.EventArgs' does not contain a definition for 'CurrentView' and no extension method 'CurrentView' accepting a first argument of type 'System.EventArgs' could be found (are you missing a using directive or an assembly reference?)

I don’t believe it is just a missing using statement, I just think that System.EventArgs doesn’t have a handle to CurrentView.

How do I see what properties the object “args” actually has contained within, so that I can access a field?

If you want to see what properties are all in args use Visual Studio in debug mode, and use a breakpoint to stop inside the method and explore the args object. Otherwise if you have a ref to the DataView otherwise using something like oTrans.Factory(“PartLot”) then just use that instead of current view and just check for Row > -1 before the rest of your logic to be a good citizen.

System.EventArgs is the bare minimum data you can get from an event, and won’t contain anything useful.

I usually find EpiDataView_AfterRowChange(EpiRowChangedArgs args) is more helpful in these cases because it lets you access the view directly instead of needing to go via the grid.

I’m using code that @josecgomez provided to populate the grid from BAQ. It’s on UD39 customisation.

Guessing that means that I don’t have an EpiDataView to go after?

If you are using a BAQDataView you do have an “EpiDataView” one inherits from the other.
So you should be able to trigger that same event.
something like

grdLotNumbers.ActiveRow.Cells["PartLot_PartNum"] etc...

It’s this code that I’m using to populate:

private void PopulateAvailableLotNumbers(string partNum)
	{
		//string strBaseAndSize = lotNum.Substring(0,6);
		
		try
		{			
			// Populate Available Samples Grid			
			DynamicQueryAdapter dqa_AvailableLots = new DynamicQueryAdapter(oTrans);
			dqa_AvailableLots.BOConnect();
			QueryExecutionDataSet qedsBAQ = dqa_AvailableLots.GetQueryExecutionParametersByID("PalleconConversionLotNumberLst");
			qedsBAQ.ExecutionParameter.Clear();
			qedsBAQ.ExecutionParameter.AddExecutionParameterRow("PartNum", partNum, "string", false, Guid.NewGuid( ), "A" );
			dqa_AvailableLots.ExecuteByID("PalleconConversionLotNumberLst", qedsBAQ );
			
			grdLotNumbers.DataSource = dqa_AvailableLots.QueryResults.Tables["Results"];

			//grdAvailableSamples.DisplayLayout.Bands[0].Columns["PartTran_TranQty"].Format = "###,##0.00";
						
		} catch (System.Exception ex)
		{
			ExceptionBox.Show(ex);
		}		
	}

This isn’t a BAQDataView is it?

No it is not, this is just running a BAQ
You should be able to use the grid event you showed above with that code snippet (or something close to it I’ll check when I get a chance)

private void grdLotNumbers_AfterRowActivate(object sender, System.EventArgs args)
{
	MessageBox.Show(grdLotNumbers.ActiveRow.Cells["PartBin_LotNum"].Value.ToString());
}

Got it to work - combination of me giving the wrong field name, and not having .Value after the cell reference.

It was making the grid go black, and only when clicking on a cell would it highlight white. Also was showing an error because it couldn’t find the field.

Once I got the field name correct, with .Value, all is working sweet.

Thank you!

1 Like