J
Joe
Hi
I am trying to allow my property grid have a property with the values are
dynamically generated at runtime
I can create a static list but not dynamic
Anyone have a suggestion or code sample on how to do this ??
Thanks
namespace MyReport{
class MyPropGrid
{
private string sTitle1 = "";
private string sTitle2 = "";
private string sLogo = "";
private int nTitleFontSz = 0;
private System.Drawing.Color cBackColor;
private bool bFreeze = true;
private bool bAlternateRow = true;
private System.Drawing.Color cAltRowColor;
private string _myProp = "entry1";
[Browsable(true)]
[DefaultValue("entry1")]
[CategoryAttribute("Data")]
[TypeConverter(typeof(MyConverter))]
public string MyProp
{
get { return _myProp; }
set { _myProp = value; }
}
}
public class MyConverter : StringConverter
{
public override bool GetStandardValuesSupported(ITypeDescriptorContext
context)
{
//true means show a combobox
return true;
}
public override bool GetStandardValuesExclusive(ITypeDescriptorContext
context)
{
//true will limit to list. false will show the list, but allow free-form
entry
return true;
}
public override System.ComponentModel.TypeConverter.StandardValuesCollection
GetStandardValues(ITypeDescriptorContext context)
{
return new StandardValuesCollection( new string[] { "entry1", "entry2",
"entry3" });
}
}
I am trying to allow my property grid have a property with the values are
dynamically generated at runtime
I can create a static list but not dynamic
Anyone have a suggestion or code sample on how to do this ??
Thanks
namespace MyReport{
class MyPropGrid
{
private string sTitle1 = "";
private string sTitle2 = "";
private string sLogo = "";
private int nTitleFontSz = 0;
private System.Drawing.Color cBackColor;
private bool bFreeze = true;
private bool bAlternateRow = true;
private System.Drawing.Color cAltRowColor;
private string _myProp = "entry1";
[Browsable(true)]
[DefaultValue("entry1")]
[CategoryAttribute("Data")]
[TypeConverter(typeof(MyConverter))]
public string MyProp
{
get { return _myProp; }
set { _myProp = value; }
}
}
public class MyConverter : StringConverter
{
public override bool GetStandardValuesSupported(ITypeDescriptorContext
context)
{
//true means show a combobox
return true;
}
public override bool GetStandardValuesExclusive(ITypeDescriptorContext
context)
{
//true will limit to list. false will show the list, but allow free-form
entry
return true;
}
public override System.ComponentModel.TypeConverter.StandardValuesCollection
GetStandardValues(ITypeDescriptorContext context)
{
return new StandardValuesCollection( new string[] { "entry1", "entry2",
"entry3" });
}
}