How to create a Visual Studio C# property that opens the edit box

Asked

Viewed 69 times

1

I’d like someone to help me with a situation. Whoever has an example please answer me. I would like to create a property in a User Control object, and that in this property opened the edit box, as an example below:

inserir a descrição da imagem aqui

Follow code from my User Control:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp13
{
    public partial class UserControl1 : UserControl
    {
        public UserControl1()
        {
            InitializeComponent();
        }

        // Propriedade para informar um texto fixo.
        public string MyObservacao { get; set; }
    }
}
  • Sorry, I couldn’t understand what you wanted to do.

  • In Visual Studio c# I created a User Control (Observacaogeral) a multi-line text box. In this User Control I created a Mytextinitial property where, when I put my control in the form I go in that property and put the text I want. Only in this property appears only one line for me to type and I would like my property to open the text box as in the example posted above. The native Text property opens the edit box. I wanted this to happen with my Mytextinitial property. Att. Gilberto Rezende.

  • Evolving... when you say Visual Studio C# and Controle de Usuário you are actually referring to a component and you want the editing of an attribute, in the properties tab of the IDE, to present as multiline? Include component code in your question.

  • Grateful. Follow code from my User Control: using System; using System.Collections.Generic; using System.Componentmodel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Windowsformsapp13 { public partial class Usercontrol1 : Usercontrol { public Usercontrol1() { Initializecomponent(); } // Property to provide a fixed text. public string Myobservacao { get; set; } } } Att. Gilberto Rezende.

  • use the edit option and put this information in the question

  • Add the reference to the System.Design in your project and the following annotation in the property where you want the editor to be multiline [Editor(typeof(MultilineStringEditor), typeof(System.Drawing.Design.UITypeEditor))]

  • Very good. Everything worked out. I am immensely grateful. Att. Gilberto Rezende.

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.