typeconverter

Using custom TypeConverters on complex custom objects that contain generic collections

I have a class, Questionnaire, which contains a collection class that wraps a generic list, EntityCollection. I am using ViewState to persist the Questionnaire and its collection of Questions. I am using custom type converters to reduce the ViewState size. Everything works without a type converter for EntityCollection<T>. Would things...

typeconverter from dll

Hi, I am using the propertygrid with a class and associated type converter. When I moved the class and the TypeConverter to a dll, it seems that it is not being called. Can't find how to activate the typeconverter from a dll. Assembly a = Assembly.LoadFile(modulepath + elementname + ".dll"); try { object myobj = a.CreateInstance(o...

TypeConverter when binding to ASP.NET GridView

I am trying to bind an IList of objects to a GridView's DataSource and one of the properties of the object is an enum. I was trying to use a TypeConverter on the enum to use a Description when the object is bound to the GridView Row. It does not look like my EnumConverter.ConvertTo method is being called. Will a TypeConverter be calle...

system.convert to custom object

we have a custom datatype object "Money" which is used to represent money values in our application. at the moment we are trying to implement some custom formatting within a grid component however the exception "InvalidCastException" is raised from System.Convert. the text from the exception is; System.InvalidCastException occurred M...

Using textbox value as parameter in LINQ dat source/gridview : A value of type 'String' cannot be converted to type 'Double'

Hello all - it's a New Year but you're still left with a thick Mr Dean!! Ok, the scenario - I have a textbox, a two radio buttons, a button and a gridview. <code> <body> <form id="form1" name="form1" runat="server"> <asp:TextBox ID="tbxHowMany" runat="server" style="z-index: 1; left: 245px; top: 105px; position: absolute; hei...

How to implement a TypeConverter for a type and property I don't own?

This is annoying: <GeometryDrawing> <GeometryDrawing.Pen> <Pen Brush="Black"/> </GeometryDrawing.Pen> </GeometryDrawing> I want this: <GeometryDrawing Pen="Black"/> So I write a TypeConverter: public class PenConverter : TypeConverter { static readonly BrushConverter brushConverter = new BrushConverter(); ...

Caching problems when developing type converters and editors in the ide for vb.net, winforms.

Any time I make a change to a type converter or editor, I have to close down my visual basic 2008 express ide and restart it. If i don't restart, the following problems occur: (1) The designer shows what appear to be random errors. I solve this by running the app, so not a real problem there. (2) Serialization of design time propertie...

How to mark a property as ReadOnly even if GetCreateInstanceSupported = true in winforms, .net

Using the CreateInstance method of the TypeConverter class, it's possible to edit the properties of an immutable object - such as a font. However, unlike the font class, there's some properties in my class that i'd like to be browsable but readonly - even though CreateInstance is supported. Is there an attribute that supports this? ET...

TypeConverter in propertygrid only converts from string, not to.

Only the ConvertTo method gets called(a lot of times) when accessing the propertygrid. This correctly returns the "Foo!" string in the propertygrid. When I click to edit I get an exception Cannot convert object of type Foo to type System.String.(not exactly, translated). The ConvertFrom method doesn't get called, any clues why? And the e...

.Net: Is there a built-in TypeConverter or UITypeEditor to edit lists of strings.

Hi everybody! I wish to know if .Net-3.5 comes with a built-in List<string> or string[] TypeConverter or UITypeEditor so that I can edit this kind of property from a property grid. ...

Copy Paste is Disabled in Property Grid

Hi All, I have a FileNameEditor inside a property grid, which has a few entries like Main File : "C:\blah1" Sec File: "C:\blah2" and so on. My problem is that I cannot copy and paste from one property entry to another, and I cannot type in the fields manually as well. Is there a specific property that will enable editing inside the...

How do you mark class with TypeConverter that is not in referenced solution?

I have a class that I've written a TypeConverter for. I want to keep the TypeConverter separate from the main solution, as it is only needed at design time and have an extensibility project now that contains the TypeConverter. Thus, when I deploy, I don't need to deploy the extensibility assembly at all. However, I can't figure out the ...

Getting TypeConverter error that makes no sense

I have a TypeConverter for a TopMostNode class. It extends ExpandableObjectConverter. The TopMostNode has two properties. Setting those in the property grid results in correctly serialized code to the designer. However, if I type in text for the property, I get a "Property value is not valid" error and the details say: Object of type...

TypeConverters on the compact framework

I'm working on a compact framework project and whilst most of the properties are fairly straight forward (I.e. mark them as browsable in the xmta file), I'm struggling to get this to work for more complex types - on the full framework, I'd just implement a custom TypeConverter and go from there, but it seems the CF TypeConverter doesn't ...

Insert custom TypeConverter on a property at runtime, from inside a custom UITypeEditor

I've created a custom UITypeEditor. Can I possibly insert an attribute that also attaches a TypeConverter to my property from inside the UITypeEditor class? I've tried the following, but nothing happens, no matter how I twist and turn it: Attribute[] newAttributes = new Attribute[1]; newAttributes[0] = new TypeConverterAttribute(type...

TypeConverter.ConvertFrom String to String

I'm using a PropertyGrid to display a property. For one property, I'm displaying strings in a drop-down combobox. The displayed text of the property and the value of the property are both strings, but their text is different. The displayed text is friendly, the value text corresponds to a registry key name. I've created a TypeConverter t...

Automapper Type Converter from String to IEnumerable<String> is not being called

Here is my custom Type Converter. public class StringListTypeConverter : TypeConverter<String, IEnumerable<String>> { protected override IEnumerable<string> ConvertCore(String source) { if (source == null) yield break; foreach (var item in source.Split(',')) yield return item.Trim(); ...

Why won't Silverlight handle the conversion of my custom float property

In a Silverlight 4 project I have a class that extends Canvas: public class AppendageCanvas : Canvas { public float Friction { get; set; } public float Restitution { get; set; } public float Density { get; set; } } I use this canvas in Blend by dragging it onto another control and setting the custom properties: ...

C - Convert long int to signed hex string

MASSIVE EDIT: I have a long int variable that I need to convert to a signed 24bit hexadecimal string without the "0x" at the start. The string must be 6 characters followed by a string terminator '\0', so leading zeros need to be added. Examples: [-1 -> FFFFFF] --- [1 -> 000001] --- [71 -> 000047] Answer This seems to do the trick: ...

Equivalent for TypeConverters for tags within property element tags?

Scenario: I'm trying to build my DataContext object tree for use as design time data. Great, awesome. Issue: I have a few types, some I control and some (such as DataRowView) that I don't, which cannot be simply new-ed up. I need some way to create instances of these types for use in my models. What I'd love is an equivalent of t...