HighTechTalks DotNet Forums  

Get the ExternaProvider Control Refrence in the UITypeEditor

Dotnet Framework (WinForms DesignTime) microsoft.public.dotnet.framework.windowsforms.designtime


Discuss Get the ExternaProvider Control Refrence in the UITypeEditor in the Dotnet Framework (WinForms DesignTime) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Ahmed Hashish
 
Posts: n/a

Default Get the ExternaProvider Control Refrence in the UITypeEditor - 09-27-2007 , 08:38 AM






Dear Sir

I created a control "MyControl" that implements the IExternalProvider Class, "MyControl" should provide the property MyProperty for all other controls.



I created also an UITypeEditor class that help the user to select "MyProperty1" form a DropDownList



My Problem is I need to get a reference for MyControl in the EditValue method of the UITypeEditor because the DropDownList changes according to other property "MyProperty2" of "MyControl".



My class code like this:

public class MyControl : UserControl, System.ComponentModel.IExtenderProvider

{

……

public string MyProperty2

{

….

}



[Editor(typeof(SaudisoftMyProperty1Editor), typeof(UITypeEditor)), DefaultValue("")]

public string GetMyProperty1(Control control)

{

……

}

……



public class MyProperty1Editor : UITypeEditor

{

….

public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)

{

……

MyControl sd =? //here I want to get MyControl

String M=sd.MyPropery2

……

return value;

}

…….

}

……

}


Reply With Quote
  #2  
Old   
Roger Stewart
 
Posts: n/a

Default Re: Get the ExternaProvider Control Refrence in the UITypeEditor - 09-27-2007 , 09:52 AM






public override object EditValue(ITypeDescriptorContext
context, IServiceProvider provider, object value)
{
if(context == null || context.Instance == null || provider
== null)
return value;

....

MyControl ctrl = context.Instance as MyControl;
if(ctrl == null) return null;

....
}


Reply With Quote
  #3  
Old   
Ahmed Hashish
 
Posts: n/a

Default Re: Get the ExternaProvider Control Refrence in the UITypeEditor - 09-30-2007 , 07:34 AM



Thanks for replay
I think you didn't got what I mean, context.Instance returns the reference of the current selected control, I need a reference for MyControl (Extender Provider) the control that provided the property the user currently editing.

best regards,
Ahmed
"Roger Stewart" <rstewart27104 (AT) gmail (DOT) com> wrote

public override object EditValue(ITypeDescriptorContext
context, IServiceProvider provider, object value)
{
if(context == null || context.Instance == null || provider
== null)
return value;

....

MyControl ctrl = context.Instance as MyControl;
if(ctrl == null) return null;

....
}


Reply With Quote
  #4  
Old   
Ahmed Hashish
 
Posts: n/a

Default Re: Get the ExternaProvider Control Refrence in the UITypeEditor - 09-30-2007 , 08:43 AM



Thanks for replay
I think you didn't got what I mean, context.Instance returns the reference of the current selected control, I need a reference for MyControl (Extender Provider) the control that provided the property the user currently editing.

best regards,
Ahmed
"Roger Stewart" <rstewart27104 (AT) gmail (DOT) com> wrote

public override object EditValue(ITypeDescriptorContext
context, IServiceProvider provider, object value)
{
if(context == null || context.Instance == null || provider
== null)
return value;

....

MyControl ctrl = context.Instance as MyControl;
if(ctrl == null) return null;

....
}


Reply With Quote
  #5  
Old   
Ahmed Hashish
 
Posts: n/a

Default Re: Get the ExternaProvider Control Refrence in the UITypeEditor - 10-01-2007 , 08:12 AM





I found it,
ExtenderProvidedPropertyAttribute EPPA = context.PropertyDescriptor.Attributes[typeof(ExtenderProvidedPropertyAttribute)] as ExtenderProvidedPropertyAttribute;

MyControl sd = (MyControl)EPPA.Provider;

thanks
Ahmed




"Ahmed Hashish" <a_hashish (AT) hotmail (DOT) com> wrote

Thanks for replay
I think you didn't got what I mean, context.Instance returns the reference of the current selected control, I need a reference for MyControl (Extender Provider) the control that provided the property the user currently editing.

best regards,
Ahmed
"Roger Stewart" <rstewart27104 (AT) gmail (DOT) com> wrote

public override object EditValue(ITypeDescriptorContext
context, IServiceProvider provider, object value)
{
if(context == null || context.Instance == null || provider
== null)
return value;

....

MyControl ctrl = context.Instance as MyControl;
if(ctrl == null) return null;

....
}


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.