Is there a built-in editor for a multi-line string in a PropertyGrid.
-
No, you will need to create what's called a modal UI type editor. You'll need to create a class that inherits from UITypeEditor. This is basically a form that gets shown when you click on the ellipsis button on the right side of the property you are editing.
The only drawback I found, was that I needed to decorate the specific string property with a specific attribute. It's been a while since I had to do that. I got this information from a book by Chris Sells called "Windows Forms Programming in C#"
There's a commercial propertygrid called Smart PropertyGrid.NET by VisualHint.
From hectorsosajr -
Yes. I don't quite remember how it is called, but look at the Items property editor for something like ComboBox
Edited: As of @fryguybob, ComboBox.Items uses the System.Windows.Forms.Design.ListControlStringCollectionEditor
fryguybob : ComboBox.Items uses the System.Windows.Forms.Design.ListControlStringCollectionEditor, I don't think that is quite what I'm looking for, but it is close.From Ilya Ryzhenkov -
I found that
System.Design.dllhasSystem.ComponentModel.Design.MultilineStringEditorwhich can be used as follows:public class Stuff { [Editor(typeof(MultilineStringEditor), typeof(UITypeEditor))] public string MultiLineProperty { get; set; } }hectorsosajr : What version of the .NET Framework did you find that in?fryguybob : http://msdn.microsoft.com/en-us/library/system.componentmodel.design.multilinestringeditor.aspx indicates that it is in 2.0, 3.0, and 3.5.Alex : How to use this? I am trying to write [Editor(typeof(MultilineStringEditor), typeof(UITypeEditor))] [CategoryAttribute("Misc"), Description("All http headers for this mail."), DisplayName("HTTP Headers")] public string HttpHeaders { get { return mail.HttpHeaders; } } but this does not display HttpHeaders as multiline.fryguybob : It is a multiline *editor* so I think you would only see a difference when editing, so it would only apply to properties with a public setter.Alex : Thanks fryguybob! Do you know a way to SHOW multiline string in a grid? Not to edit? Thanks!From fryguybob
0 comments:
Post a Comment