|
Hi, I need a little help with interfaces. I have created an interface: public interface ILookUpDispacher { bool LookUp(string entityName, ref object objectToReturn); } and a component with this property: private ILookUpDispacher _LookUpDispacher; public ILookUpDispacher LookUpDispacher { get { return _LookUpDispacher; } set { _LookUpDispacher = value; } } I also have a class which implements ILookUpDispacher interface: public class TestLookUpDispacher : ILookUpDispacher { public TestLookUpDispacher() { } public bool LookUp(string s, ref object o) { return false; //It actually does more but nothing relevant to show here } } In my form I have an instance of that class: public partial class XtraForm1 : DevExpress.XtraEditors.XtraForm { public TestLookUpDispacher lkpDispacher; public XtraForm1() { InitializeComponent(); lkpDispacher = new TestLookUpDispacher(); } . . . } Now, I want to select lkpDispacher from the drop down list of my control's LookUpDispacher property, but it doesn't show up there. Why? Am I doing something wrong? I'm especially afraid that I missed the whole concept :) Thanks in advance! - Edited byAnil Mujagic Wednesday, July 08, 2009 11:56 PM
- Edited byAnil Mujagic Thursday, July 09, 2009 12:12 AM
- Moved byDaniel Rieck Thursday, July 09, 2009 11:40 AMQuestion about WinForms designer integration (From:Visual C# General)
-
|
| Anil Mujagic Wednesday, July 08, 2009 11:45 PM |
Perhaps you should try posting to the Windows Forms Designer forum instead, where it is more on topic. Basically the designer only cares about components and controls, not private fields you add yourself.
Mattias, C# MVP - Marked As Answer byAnil Mujagic Thursday, July 09, 2009 12:21 PM
-
|
| Mattias Sjögren Thursday, July 09, 2009 8:51 AM |
7 hours no reply... OK I'm in panic :) |
| Anil Mujagic Thursday, July 09, 2009 6:50 AM |
Perhaps you should try posting to the Windows Forms Designer forum instead, where it is more on topic. Basically the designer only cares about components and controls, not private fields you add yourself.
Mattias, C# MVP - Marked As Answer byAnil Mujagic Thursday, July 09, 2009 12:21 PM
-
|
| Mattias Sjögren Thursday, July 09, 2009 8:51 AM |
How is your DropDownList control linked to your lkpDispatcher class? I think I'm missing the point... |
| t0x1 Thursday, July 09, 2009 9:22 AM |
How is your DropDownList control linked to your lkpDispatcher class? I think I'm missing the point...
Yes you are a little bit missing the point ;) It's not the DropDownList control, it's a custom control. ". . . I want to select lkpDispacher from the drop down list of my control's LookUpDispacher property . . ." My custom control has the property, and I want to assign an instance of a class(which implements ILookUpDispacher interface) to it, but I want to do it using designer (Property window). Mattias gave me a hint... I will probably need to create component which implements ILookUpDispacher interface, to be able to see it in the designer. But, before I do this, I need to know if declaring the property by using the interface is ok or not? |
| Anil Mujagic Thursday, July 09, 2009 9:58 AM |
Using an interface should be ok. The way to define behaviorfor the designer's property window is to add an Editor attribute to aproperty. I think you need to implement an editor that looks for instances of ILookUpDispatcher on the form, and apply that to your controls LookUpDispatcher property. The WinForms Designer forum is definitely the better place to ask. Mark the best replies as answers! |
| Daniel Rieck Thursday, July 09, 2009 11:39 AM |
Using an interface should be ok. The way to define behaviorfor the designer's property window is to add an Editor attribute to aproperty. I think you need to implement an editor that looks for instances of ILookUpDispatcher on the form, and apply that to your controls LookUpDispatcher property. The WinForms Designer forum is definitely the better place to ask.
Mark the best replies as answers!
OK, I'll try to implement the editor. P.S. Thanks for moving my thread to the right place ;) |
| Anil Mujagic Thursday, July 09, 2009 12:02 PM |
Perhaps you should try posting to the Windows Forms Designer forum instead, where it is more on topic. Basically the designer only cares about components and controls, not private fields you add yourself.
Mattias, C# MVP
Yessss! I created a component that implements my interface, and it instantly showed up in the drop down list of my control's property! No custom editor required. Thanks for the hint Mattias! |
| Anil Mujagic Thursday, July 09, 2009 12:21 PM |
After rebuilding the project, I couldn't get components to show up in drop down list. But then I found solution here in a little "Note" section at the bottom of the page. Basically I just had to replace this line in AssemblyInfo.cs file: AssemblyVersion("1.0.0.0") with this one: AssemblyVersion("1.0.*") and components were in the drop down list again. It helped despite the fact that I wasn't actually making custom property editor. I hope this will be useful to future readers of this thread. |
| Anil Mujagic Thursday, July 09, 2009 6:25 PM |