Author Topic: TextAlternate multiline  (Read 1309 times)

Phrog30

  • Guest
TextAlternate multiline
« on: August 18, 2017, 04:07:11 PM »
On the basicbutton, the text property allows multi line entry.  There is a drop that makes it simple.  Is it possible to add this feature to the textalternate property?

James

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5324
    • View Profile
    • AdvancedHMI
Re: TextAlternate multiline
« Reply #1 on: August 18, 2017, 04:47:23 PM »
Edit BasicButton.vb and tell Visual Studio that you want to use a multiline editor for the property by applying an attribute to the property like this:

    <System.ComponentModel.Editor(GetType(System.ComponentModel.Design.MultilineStringEditor), GetType(System.Drawing.Design.UITypeEditor))> _
    Public Property TextAlternate() As String

Phrog30

  • Guest
Re: TextAlternate multiline
« Reply #2 on: August 18, 2017, 04:53:31 PM »
Awesome, thank you!!

Phrog30

  • Guest
Re: TextAlternate multiline
« Reply #3 on: August 18, 2017, 05:07:22 PM »
I couldn't get your snippet to work, I ended up with this...
Code: [Select]
<EditorAttribute("System.ComponentModel.Design.MultilineStringEditor, System.Design", "System.Drawing.Design.UITypeEditor")>
 Public Property TextAlternate() As String

I'm guessing I was missing a reference to something, but couldn't figure out what.  Your post helped me Google what I needed, thanks.

James

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5324
    • View Profile
    • AdvancedHMI
Re: TextAlternate multiline
« Reply #4 on: August 18, 2017, 05:19:24 PM »
Were you getting an error from the code I posted? I tried it out and it worked for me. One thing I did notice about VS2017 is that when you make a change to a control, just building the solution is not enough. If you have the form open, you must close it and re-open for it to take the changes in the designer.

Phrog30

  • Guest
Re: TextAlternate multiline
« Reply #5 on: August 18, 2017, 05:42:59 PM »
I get an error in designer, says Type "System.ComponentModel.Design.MultilineStringEditor" is not defined.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5324
    • View Profile
    • AdvancedHMI
Re: TextAlternate multiline
« Reply #6 on: August 18, 2017, 05:54:03 PM »
I see what it is. I had a reference to System.Design in the project I tried it on.

Phrog30

  • Guest
Re: TextAlternate multiline
« Reply #7 on: August 18, 2017, 06:37:56 PM »
Simple enough, I thought I tried adding that.  According to the site I got the snippet I used, you don't need to reference anything.