Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
D

Deglimmer

@Deglimmer
About
Posts
1
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • problem with propertygrid
    D Deglimmer

    Hi, im using propertygrid and trying to show boolean property with other string values than true/false, i made boolenconverter for this, it works fine when i use combobox to change value, but i get inner propertygrid error when i doubleclick to change value in propertygrid: Invalid property value! Details: Cannot widen from target type to primitive type. public class BaseProps{ private bool test; [TypeConverter(typeof(BoolNameConverter2))] public bool Value { get {return test;} set {test = value;} } } public class BoolNameConverter2 : StringConverter { private const string m_trueDisplayName = "on"; private const string m_falseDisplayName = "off"; public override bool CanConvertTo(ITypeDescriptorContext context, System.Type destinationType) { if (destinationType == typeof(bool)) return true; return base.CanConvertTo(context, destinationType); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, System.Type destinationType) { if (value is bool && destinationType == typeof(System.String)) { return (bool)value ? m_trueDisplayName : m_falseDisplayName; } return base.ConvertTo(context, culture, value, destinationType); } public override bool CanConvertFrom(ITypeDescriptorContext context, System.Type sourceType) { if (sourceType == typeof(string)) return true; return base.CanConvertFrom(context, sourceType); } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string) { return (string)value == m_trueDisplayName ? true : false; } return base.ConvertFrom(context, culture, value); } public override bool GetStandardValuesSupported( ITypeDescriptorContext context) { return true; } public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { return new StandardValuesCollection (new string[]{m_trueDisplayName, m_falseDisplayName}); } public override bool GetStandardValuesExclusive( ITypeDescriptorContext context) { return true; } } What could be the problem? Has anybody had similar problem and has solution? How to fix it? Thanks Deglimmer

    C# help tutorial question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups