Jay1b Posted April 5, 2005 Posted April 5, 2005 I have created a class which stores information which will be displayed within a listview. A timer calls a procedure that refreshes the listview from this class, unfortunately this creates a flickering effect. 'IntegerA POSSIBLY changed IF IntegerA <> IntegerB THEN 'refresh listview IntegerB = IntegerA END IF The above example would only refresh if IntegerA HAD changed. Could someone please explain how can i do something similar to this with classes please? Thanks Quote
Mister E Posted April 5, 2005 Posted April 5, 2005 Why not just create an integer property that you can use for comparison purposes? If you want to naturalize things a bit then you could overload the equality operators. Quote
Jay1b Posted April 6, 2005 Author Posted April 6, 2005 Thanks but I thought about that, but it just seems very amateur'ish. There must be a way of comparing two instances of the same class. Quote
michael_hk Posted April 6, 2005 Posted April 6, 2005 Take a look at the IComparable interface. Quote There is no spoon. <<The Matrix>>
Leaders snarfblam Posted April 6, 2005 Leaders Posted April 6, 2005 I think IComparable is more meant for sorting or finding when an object is greated or less than another (Although if IComparable.CompareTo() returns a zero, it does signify equality, it is generally used for sorting of collections). Since you only want to test for equality, I recommend overriding the .Equals() method. Since you are using VB, you can't overload the = operator. Quote [sIGPIC]e[/sIGPIC]
Jay1b Posted April 6, 2005 Author Posted April 6, 2005 In the end i remembered there was a sequence number variable in the class, i just use this to compare to an integer. Much easier :D Didnt want to create an integer special though. Quote
Mister E Posted April 6, 2005 Posted April 6, 2005 Well, you wouldn't need to create a new variable. That's the point of a read only property. Quote
IngisKahn Posted April 6, 2005 Posted April 6, 2005 Mr. eater is sorta right :), you want to override AND overload Equals(), you don't want to expose a new property. Quote "Who is John Galt?"
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.