|
From: | Francisco Figueiredo Jr. |
Subject: | Re: [DotGNU]Winforms StatusBar |
Date: | Tue, 17 Jun 2003 22:24:52 -0300 |
User-agent: | Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4b) Gecko/20030506 Thunderbird/0.1a |
Simon Guindon wrote:
k so I've hit a little bit of an implementation wall trying to implement StatusBar. The problem is in the StatusBarPanelCollection, it inherits from IList, ICollection, Ienumerable. Ilist requires it to implement the Add(object) and such methods, but if you look at the MSDN docs, there is no such thing, it has Add(StatusBarPanel). So I decided to implement both, it compiles fine, but in the designer it does not react properly, when you use designer to add panels it adds it as Object and that's wrong because now you can't adjust the correct properties because their not exposed. If I don't implement the Add(object) method it just complains because it needs to be implemented. So how do I get around this?
You have to implement the IList as an explicit interface implementation. So, instead of having public int Add(Object value) you do it like this: int IList.Add(Object value) and later you can add your public int Add(StatusBarPanel panel) There are a lot of implementations like this in the MS implementation.A classic example is the Int32 structure. You can see that it implements the IComparable, IFormattable and IConvertible interfaces, but in the Int32 members you don't see any mention of IConvertible implemented methods! For more information, please check the excellent book: Applied Microsoft .Net Framework Programming by Jeffrey Richter check the section: Explicit Interface Member Implementation and the section Be careful with Explicit Interface Method Implementation where he says that MS decided to implement the IConvertible as explicit interface just because she didn't want to bloat the Int32 and others documentation with all that methods! :)
I hope it helps. -- Regards, Francisco Figueiredo Jr. ------ "My grandfather once told me that there are two kinds of people: those who work and those who take the credit. He told me to try to be in the first group; there was less competition there." - Indira Gandhi
[Prev in Thread] | Current Thread | [Next in Thread] |