Hello,
I am using the UltraWinGrid. I specify the data source as an interface. In the form load event I set the datasource to an instance of a class that implements this interface. The cl***ructure looks like this:
public
class BaseClass : IBaseInterface
IDerivedInterface : IBaseInterface
The problem is that the properties defined in IBaseInterface and implemented in BaseClass (that DerivedClass inherits) don't show up in the designer under Band & Col. Settings->Columns.. Thus I can't remove them and they show up in the grid. How does one handle this? I believe I can solve the problem by specifiying the bindingsource as DerivedClass rather than IDerivedInterface but I'd rather not do this as the real project has several class that dervice from IDerivedInterface and could be used.
Suggestions? I have attached the very simple demo project that displays this behaviior.
Thanks.
Interesting problem... although it tells you that interface "Inheritance" is not like class inheritance. The properties of IBaseInterface don't belong to IDerivedInterface. It just say: "if you're going to implement IDerivedIterface, please implement IBaseInterface too". As another proof, you can explicitly implement IDerivedInterface. You can see that properties of IDerivedInterface are implemented like:
bool IDerivedInterface.DerivedProperty1
but properties of IBaseInterface are implemented as:
bool IBaseInterface.BaseProperty1
The only option I see here if you want to keep binding to interface type, break the interface "inheritance" and copy properties to IDerivedInterface. In the class, one property can serve both interfaces.
Amiram,
Thank you for the comments. However, I'm not sure they answer my question. Let me state the question another way:
Given the class/interface structure I mentioned, how does one pick which columns will show up in the grid. I want to have some of the derived interface/cl***properties and some of the base interface/cl***properties, but not all of them.
Perhaps there is a way to add them one by one in the designer? Perhaps there is a simple way to do it without the designer.
Thanks,
I think you can add them manually, but it requires more work. If you want that a property won't be shown, you can put the attribute [Browsable(false)] above it, or set the column.Header.Hidden to true.
Attached.
This is what I changed:
1. IDerivedInterface is no longer inheriting IBaseInterface.
2. IDerivedInterface has also the properties that IBaseInterface has.
3. DerivedProperty2 has the attribute [Browsable(false)] in the interface, but [Browsable(true)] in the class (not necessary). I don't think it can effect anything other than binding.
4. Column BaseProperty1 is hidden by designer.
You need to change reference to 8.2. I stiil use 8.1.
Can you provide an example? How can you set the column.Header.Hidden to true when the (base) property does not even show up in the designer? Or do you mean it can be done from code? I'm not sure what you mean by setting the attribute [Browsable(false)] for certain properties. Why would I want to limit how others are using the propererties? Surely there is a way to do it with the grid itself.
If you could take my example and fix it up, it would be much appreciated.
Andrew