Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6221635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:10:09+00:00 2026-05-24T08:10:09+00:00

What is the easiest way to have Visual Studio-like editor for string in PropertyGrid?

  • 0

What is the easiest way to have Visual Studio-like editor for string in PropertyGrid? For example in Autos/Locals/Watches you can preview/edit string values in-line but you can also click on magnifying glass and see string in external window.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T08:10:10+00:00Added an answer on May 24, 2026 at 8:10 am

    You can do this via a UITypeEditor, as below. Here I’m using it on an individual property, but IIRC you can also subvert all strings (so that you don’t need to decorate all the properties):

    using System;
    using System.ComponentModel;
    using System.Drawing.Design;
    using System.Windows.Forms;
    using System.Windows.Forms.Design;
    
    static class Program
    {
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            using(var frm = new Form { Controls = { new PropertyGrid {
                Dock = DockStyle.Fill, SelectedObject = new Foo { Bar = "abc"}}}})
            {
                Application.Run(frm);
            }
        }
    }
    
    class Foo
    {
        [Editor(typeof(FancyStringEditor), typeof(UITypeEditor))]
        public string Bar { get; set; }
    }
    class FancyStringEditor : UITypeEditor
    {
        public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
        {
            return UITypeEditorEditStyle.Modal;
        }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            var svc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            if (svc != null)
            {
                using (var frm = new Form { Text = "Your editor here"})
                using (var txt = new TextBox {  Text = (string)value, Dock = DockStyle.Fill, Multiline = true })
                using (var ok = new Button { Text = "OK", Dock = DockStyle.Bottom })
                {
                    frm.Controls.Add(txt);
                    frm.Controls.Add(ok);
                    frm.AcceptButton = ok;
                    ok.DialogResult = DialogResult.OK;
                    if (svc.ShowDialog(frm) == DialogResult.OK)
                    {
                        value = txt.Text;
                    }
                }
            }
            return value;
        }
    }
    

    To apply this for all string members: instead of adding the [Editor(...)], apply the following somewhere early in the app:

    TypeDescriptor.AddAttributes(typeof(string), new EditorAttribute(
         typeof(FancyStringEditor), typeof(UITypeEditor)));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone please point me to the easiest way to have a timer in
I'd like my application to have a full-screen mode. What is the easiest way
Visual Studio has a way to import, export your color settings. Does Eclipse have
What would be the easiest way to have a page where it will display
What would be the easiest way to have the color of a text field
What is the easiest way to convert xml to html? I have xml file
What is the easiest way to ping/notify a .NET Windows Service? Do I have
i have a database of links and tags. what is the easiest way i
I have a Spring controller that returns XHTML, what's the easiest way to setup
I have dates in the following format (yyyymmdd, 18751104, 19140722)... what's the easiest way

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.