I have a list of zipcode objects that I bind to a datagridview based on a selection from a treeview, the treeview is unimportant other than only a subset of available zipcodes are bound to the grid at any one time.
where GetForZipPart has a function signature of:
I want to select items in the gridview based upon another list of ZipGeoCode objects that correspond to a dealer. The dealer list may contain zipcodes from other zipparts that are not bound to the grid. I do the selection like so:
so far so good, however now when an item is selected or deselected in the radgridview I want to add or remove it from the _dealerZipCodes in the most efficient manner. I suspect i shoudl use the radgrdiview_selectionchanged event. I am wondering if ther is a way to do this with observable collections?. Any suggestions greatly appreciated and info how I can act only on the item(s) that were selected/deselected by accessing the
I'm not using MVVM.
Currently my radgrdiview_selectionchanged looks like the following:
Not very efficient.
Thanks for the help/direction.
For a visual of what I'm doing: http://www.metamorpho-sys.com/telerik/Capture.GIF
Jonathan
GridSelectedZipCodes.ItemsSource = ZipGeoCodeService.GetForZipPart((string)item.Header, (float)_selectedDealer.Latitude, (float)_selectedDealer.Longitude, (float)_selectedDealer.MaxDistance);where GetForZipPart has a function signature of:
static public List<ZipGeoCode> GetForZipPart(string zippart, float latitude, float longitude, float distance)I want to select items in the gridview based upon another list of ZipGeoCode objects that correspond to a dealer. The dealer list may contain zipcodes from other zipparts that are not bound to the grid. I do the selection like so:
private void SelectZipCodes() { IsLoading = true; foreach (ZipGeoCode _item in GridSelectedZipCodes.Items) { if (_dealerZipCodes.Find(delegate(ZipGeoCode zgc) {return zgc.ID == _item.ID; }) != null) { GridSelectedZipCodes.SelectedItems.Add(_item); } } IsLoading = false; } so far so good, however now when an item is selected or deselected in the radgridview I want to add or remove it from the _dealerZipCodes in the most efficient manner. I suspect i shoudl use the radgrdiview_selectionchanged event. I am wondering if ther is a way to do this with observable collections?. Any suggestions greatly appreciated and info how I can act only on the item(s) that were selected/deselected by accessing the
SelectionChangeEventArgs
would be great.I'm not using MVVM.
Currently my radgrdiview_selectionchanged looks like the following:
private void GridSelectedZipCodes_SelectionChanged(object sender, SelectionChangeEventArgs e) { if (!(IsLoading)) { //remove all items foreach (ZipGeoCode _item in GridSelectedZipCodes.Items) { if (_dealerZipCodes.Find(delegate(ZipGeoCode zgc) { return zgc.ID == _item.ID; }) != null) { _dealerZipCodes.Remove(_item); } } foreach (ZipGeoCode _item in GridSelectedZipCodes.SelectedItems) { _dealerZipCodes.Add(_item); } } }Not very efficient.
Thanks for the help/direction.
For a visual of what I'm doing: http://www.metamorpho-sys.com/telerik/Capture.GIF
Jonathan