none
How do I add a multi-line TextBox to a PropertyGrid? RRS feed

  • Question

  • I have a standard PropertyGrid and I want to add a filed that will handle a multi-line TextBox. Any ideas?

    Thanks,
    Tim

    Tim

    Tuesday, February 26, 2019 5:54 PM

Answers

  • What I really needed was to use "MultilineStringEditor", but I kept getting the error "System.ComponentModel.Design.MultilineStringEditor Not Defined". I had the "Imports" correct in my code, but was missing the "References"

    Tim

    Imports System.ComponentModel.Design
    Imports System.Drawing.Design
    
        <CategoryAttribute("Command"),
        DefaultValue(""),
        Editor(GetType(System.ComponentModel.Design.MultilineStringEditor), GetType(System.Drawing.Design.UITypeEditor)),
        DescriptionAttribute("Init Command String for the auxiliary device")>
        Public Property InitCommandString As String
            Get
                Return _InitCommandString
            End Get
            Set(ByVal value As String)
                _InitCommandString = value
            End Set
    
        End Property
    
    Then I needed to add a Reference to "System.Design" and "System.Drawing"

    • Marked as answer by Tim8w Tuesday, February 26, 2019 9:45 PM
    • Edited by Tim8w Tuesday, February 26, 2019 11:04 PM Explanation requested
    Tuesday, February 26, 2019 9:45 PM

All replies

  • What I really needed was to use "MultilineStringEditor", but I kept getting the error "System.ComponentModel.Design.MultilineStringEditor Not Defined". I had the "Imports" correct in my code, but was missing the "References"

    Tim

    Imports System.ComponentModel.Design
    Imports System.Drawing.Design
    
        <CategoryAttribute("Command"),
        DefaultValue(""),
        Editor(GetType(System.ComponentModel.Design.MultilineStringEditor), GetType(System.Drawing.Design.UITypeEditor)),
        DescriptionAttribute("Init Command String for the auxiliary device")>
        Public Property InitCommandString As String
            Get
                Return _InitCommandString
            End Get
            Set(ByVal value As String)
                _InitCommandString = value
            End Set
    
        End Property
    
    Then I needed to add a Reference to "System.Design" and "System.Drawing"

    • Marked as answer by Tim8w Tuesday, February 26, 2019 9:45 PM
    • Edited by Tim8w Tuesday, February 26, 2019 11:04 PM Explanation requested
    Tuesday, February 26, 2019 9:45 PM
  • What I really needed was to use "MultilineStringEditor", but I kept getting the error "System.ComponentModel.Design.MultilineStringEditor Not Defined". I had the "Imports" correct in my code, but was missing the "References"

    Tim

    Hi

    Seemsmyou have already found the answer. Pity you didn't share it with us though .................

    Here is what I thought you wanted - but now I think I was way off course.

    ' Form1 with Multiline TextBox1
    ' a plain text file in My.Resources
    ' called TestFile
    Option Strict On
    Option Explicit On
    Public Class Form1
      Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    
        TextBox1.Text = My.Resources.TestFile
    
        Dim propertyGrid1 As New PropertyGrid()
        With propertyGrid1
          .CommandsVisibleIfAvailable = True
          .Location = New Point(10, 20)
          .Size = New Size(400, 300)
          .TabIndex = 1
          .Text = "Property Grid"
          .SelectedObject = TextBox1
        End With
        Controls.Add(propertyGrid1)
      End Sub
    End Class


    Regards Les, Livingston, Scotland

    Tuesday, February 26, 2019 10:37 PM