Original User: aaronnoriegaahh thanks very much, yeah def still learning. have left ole VB and began using C# aww sooo much better!!!. Now I am still a bit stuck though looking at the Mapdisplay.graphics trying to pull a particular item from the Collection. still trying to figure out the Contains method kinda of seems 'not too powerful' I guess if you need to move it comes in help. Also doesn't look like you can use LINQ against the collection either???
Brian
want-to-be-programmer
I haven't tested this code, but this should give you a general idea on how to employ LINQ to query graphic attributes
public class WidgetItem{//user class to define associated attributes to Graphic Objects
public string Name { get; set; }
public DateTime DateAdded { get; set; }
public Graphic Graphic { get; set; }
public WidgetItem (){
this.DateAdded = DateTime.Now;
}
}
List<WidgetItem> widgets = new List<WidgetItem>();
// Create and populate Widget Objects
WidgetItem wi = new WidgetItem();
wi.Name = "Brian";
wi.Graphic = somegraphic; //probably the result of a track() operation
widgets.Add(wi);
var removeus = (from w in widgets
where w.Name.StartsWith("B") && w.Graphic != null
select w.Graphic);
ActiveMapDisplay.Graphics.Remove(removeus);
You can further increase the capabilities of the WidgetItem class by implementing the IComparable<T> and IEquatable<T> templates; as well as overriding the GetHashCode and Equals functions.