no link between a property in propertygrid and attribute System.Componentmodel editor

D

dan

I have build an add-in to visualstudio to assist and help the
programmer while working in visual studio enterprise manager for many
tasks not supported by the enterprise manager.
So while developping the programmer can interract with a form that
contain a system.windows.forms.propertygrid and could show by a simple
mouseclick all the storedprocedures in the database
but it doesnt acts nothing happened i don't understand why?
the code used is:

public class Editor : System.Drawing.Design.UItypeEditor
{
private ComboBox cb;
private IWindowsFormsEditorService edSvc = null;

public Editor()
{
}

public override object EditValue(ITypeDescriptorContext context,
IServiceProvider provider, object value)
{
if (context != null
&& context.Instance != null
&& provider != null)
{
edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
if (edSvc != null)
{
string oldSelectedValue = "";
cb = new ComboBox();
cb.Size = new System.Drawing.Size(300,100);
cb.Sorted = true;
SQLDemoHelper helper = new SQLDemoHelper();
helper.Connect();
foreach(string s in helper.GetAllStoredProcedures())
{
cb.Items.Add(s);
}
helper.DisConnect();
cb.SelectedValueChanged += new EventHandler(this.ValueChanged);
if ( value is string )
{
oldSelectedValue = value as string;
cb.SelectedValue = value;
}
else
{
Debug.WriteLine(value.GetType().FullName);
}
edSvc.DropDownControl(cb);
if ( cb.SelectedValue == null )
{
if ( cb.SelectedItem == null )
{
return oldSelectedValue;
}
else
{
value = (string)cb.SelectedItem;
}
}
else
{
value = (string)cb.SelectedValue; }
}
}
return value;
}

public override UITypeEditorEditStyle
GetEditStyle(ITypeDescriptorContext context)
{
if (context != null && context.Instance != null)
{
return UITypeEditorEditStyle.DropDown;
}
return base.GetEditStyle(context);
}

private void ValueChanged(object sender, EventArgs e)
{
if (edSvc != null)
{
edSvc.CloseDropDown();

}
}

}


// and this is the property that i want to show in the propertygrid

[System.ComponentModel.Description("InsertProcedure")]
[System.ComponentModel.Category("stored Procedure")]
[System.ComponentModel.Editor( typeof(Editor),
typeof(System.Drawing.Design.UITypeEditor) )]

public string InsertProc
{
get
{
if( this.datatableRow.IsInsert_Proc_44Null() )
{
return "No inser procedure selected";
}
else
{
return this.datatableRow.Insert_Proc_44;
}
}
set
{
this.datatableRow.Insert_Proc_44 = value;
}
}

this property is a part of a class called datatableProperty
instances of this class are given to property grid

NB:I have already wrote the same code in another windows application
but without addin and its working well
thanks
 

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