AdvancedHMI Software

General Category => Support Questions => Topic started by: Phrog30 on August 18, 2017, 04:07:11 PM

Title: TextAlternate multiline
Post by: Phrog30 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
Title: Re: TextAlternate multiline
Post by: Archie 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
Title: Re: TextAlternate multiline
Post by: Phrog30 on August 18, 2017, 04:53:31 PM
Awesome, thank you!!
Title: Re: TextAlternate multiline
Post by: Phrog30 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
Title: Re: TextAlternate multiline
Post by: Archie 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.
Title: Re: TextAlternate multiline
Post by: Phrog30 on August 18, 2017, 05:42:59 PM
I get an error in designer, says Type "System.ComponentModel.Design.MultilineStringEditor" is not defined.
Title: Re: TextAlternate multiline
Post by: Archie 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.
Title: Re: TextAlternate multiline
Post by: Phrog30 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.