Any way to achieve Sticky reference?
Posted on 2004-09-25
Here is an example to hopefully help clarify what I'm trying to do.
I load a collection with objects (TestClass). I then bind this collection to a datagrid. I then also bind text a text box to the current row in the gird like this:
grdList.DataSource = myCollection;
_refClass = (TestClass)myCollection[grdList.CurrentRowIndex];
The obviously the variable _refClass is just acting as a pointer which holds a reference to the item in the collection and then that reference is bound to the textbox. So if in the future _refClass is set to another item in the collection the TextBox will not reflect that change unless it is rebound.
However, what I'd like to know is, is there a way actually bind the textbox to _refClass so that any time _refClass is pointed to a new item in the collection the TextBox will reflect this without having to be rebound.
The scenerio above isn't a real project I'm working on, I just thought it was the easist way to explain what I am looking for. I have also coded this into a simple project as an example. If it will help anyone to understand the issue I can email the project to them.
Thanks so much for your time!