المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Problem with PropertyGrid



C# Programming
04-06-2009, 05:01 PM
Hi,
I am basically a VC++ developer but now working on C#.
I am having a assembly in that i have added a UserControl and on that UserControl I am having a tree-view control and Property Grid control. As and when user selects the different nodes I am populating the corresponding properties in that grid. For the normal properties its working perfectly. But when I have to choose the property from the drop-down list. Its creating the problem. Whenever I click on the drop-down arrow nothing happens.
So I created a test application. Took a windows form application added property grid, added a class deriving it from StringConverter. Everything works fine in test application. But I don't know why its failing in my production code.
I debugged both codes. In test application whenever I click on the drop-down arrow call is coming inside GetStandardValues function. But this is not happening in my main code, its not hitting the break-point at all.

Can anybody tell me why this is happening, Where I am going wrong?
the test application code is below. The exact code is present in my main code

namespace PropertyPage
{
class MyProperties:StringConverter
{
private double str1;
private string str2;
private string str3;

public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
//return base.GetStandardValuesSupported(context);
return true;
}
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
{
//return base.GetStandardValuesExclusive(context);
return true;
}
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
return new StandardValuesCollection(new string[] { "Entry1", "Entry2", "Entry3" });
}

[CategoryAttribute("Task "), DescriptionAttribute("test"), TypeConverter(typeof(MyProperties))]
public string Str3
{
get { return str3; }
set { str3 = value; }
}
[CategoryAttribute("Task "), DescriptionAttribute("test"), ReadOnly(true)]
public double Str1
{
get { return str1; }
set { str1 = value; }
}
[Editor(typeof(System.Windows.Forms.Design.FolderNameEditor), typeof(System.Drawing.Design.UITypeEditor))]
public string Str2
{
get { return str2; }
set { str2 = value; }
}
}
}

I am initializing the grid as

private void Form1_Load(object sender, EventArgs e)
{
MyProperties my = new MyProperties();
my.Str1 = 12;
propertyGrid1.SelectedObject = my;
}

I have observed similar behavior with Str2 Property. Its not allowing me to set the path in my main code but in test application its doing its job.