I suggest you have a look at HmiScreen and SubscribeToMany projects in the <a href="/LinkClick.aspx?fileticket=4oAFG9G67Rs%3d&tabid=195">Bonus Pack. They both use similar techniques to those you need, except that the subscribe/unsubscribe is not that dynamic as you plan to do with the grid.
For example, the following snippet from SubscribeToMany illustrates a lot:
private void startButton_Click(object sender, EventArgs e)
{
int numberOfItems = (int)this.numberOfItemsNumericUpDown.Value;
this.startButton.Enabled = false;
this.numberOfItemsNumericUpDown.Enabled = false;
var argumentArray = new DAItemGroupArguments[numberOfItems];
for (int i = 0; i < numberOfItems; i++)
{
var listViewItem = new ListViewItem();
this.valuesListView.Items.Add(listViewItem);
int copy = (i / 100) + 1;
int phase = (i%100) + 1;
string itemID = String.Format("Simulation.Incrementing.Copy_{0}.Phase_{1}", copy, phase);
argumentArray = new DAItemGroupArguments("", "OPCLabs.KitServer.2", itemID, 50, listViewItem);
}
this.changeCount = 0;
this.startTickCount = Environment.TickCount;
this.timer1.Start();
this.easyDAClient1.SubscribeMultipleItems(argumentArray);
}
private void easyDAClient1_ItemChanged(object sender, EasyDAItemChangedEventArgs e)
{
this.changeCount++;
var listViewItem = (ListViewItem)e.State;
string text;
if (e.Exception != null) text = "*Error*";
else text = e.Vtq.DisplayValue();
listViewItem.Text = text;
}
In startButton_Click, you can see how listViewItem is used as last ('state') argument of DAItemGroupArguments constructor; these objects then make up the array that is passed to SubscribeMultipleItems. In easyDAClient1_ItemChanged, you can see how the 'state' is typecasted back to the control reference (which, I suppose, will be a grid cell reference in your case), and the control is updated with the new value converted to string.