problem with IExtenderProvider

M

Martin

I'm implemented a class called MyProvider which inherited from Component and
IExtenderProvider. i have the problem, that when I typed anything in the
visual studio designer in my MyItem-object which is provided by MyProvider,
the data is lost, after I clicked in another textbox. i added the following
methods in my provider:

[ProviderProperty("MyProvider", typeof(Control)]
public class MyProvider : Component, IExtenderProvider {

[ExtenderProvidedProperty]
[TypeConverter(typeof(MyItemConverter))]
public MyItem GetMyProvider(Control control) { }

[ExtenderProvidedProperty]
public void SetMyProvider(Control extendee, MyItem value) { }

public bool ShouldSerializeMyProvider(Control extendee) {}

}

my MyItem class has 4 properties. 2 of them are hidden for the designer
serialization.the last 2 properties are of type string.

any ideas why he deletes the entered data?
 
N

Nick Hounsome

Martin said:
I'm implemented a class called MyProvider which inherited from Component
and IExtenderProvider. i have the problem, that when I typed anything in
the visual studio designer in my MyItem-object which is provided by
MyProvider, the data is lost, after I clicked in another textbox. i added
the following methods in my provider:

[ProviderProperty("MyProvider", typeof(Control)]
public class MyProvider : Component, IExtenderProvider {

[ExtenderProvidedProperty]
[TypeConverter(typeof(MyItemConverter))]
public MyItem GetMyProvider(Control control) { }

[ExtenderProvidedProperty]
public void SetMyProvider(Control extendee, MyItem value) { }

public bool ShouldSerializeMyProvider(Control extendee) {}

}

my MyItem class has 4 properties. 2 of them are hidden for the designer
serialization.the last 2 properties are of type string.

any ideas why he deletes the entered data?

Because you are not saving it anywhere.
Let's see the actual method code.
 
M

Martin

Ok i found the bug... it was an oversight

in my Get method I created a new instance of my object and returned it. the
problem was that i didn't add the new instance to my internal collection.

but i have an onther problem too. when I'm trying to save the project with
my provider. I got an error "An error occurred while code generation for the
MyProvider-Property. the object rereference hasn't got a object instance."

maybe its a problem with my converter?

Nick Hounsome said:
Martin said:
I'm implemented a class called MyProvider which inherited from Component
and IExtenderProvider. i have the problem, that when I typed anything in
the visual studio designer in my MyItem-object which is provided by
MyProvider, the data is lost, after I clicked in another textbox. i added
the following methods in my provider:

[ProviderProperty("MyProvider", typeof(Control)]
public class MyProvider : Component, IExtenderProvider {

[ExtenderProvidedProperty]
[TypeConverter(typeof(MyItemConverter))]
public MyItem GetMyProvider(Control control) { }

[ExtenderProvidedProperty]
public void SetMyProvider(Control extendee, MyItem value) { }

public bool ShouldSerializeMyProvider(Control extendee) {}

}

my MyItem class has 4 properties. 2 of them are hidden for the designer
serialization.the last 2 properties are of type string.

any ideas why he deletes the entered data?

Because you are not saving it anywhere.
Let's see the actual method code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top