-
May 6th, 2023, 02:02 PM
#1
Thread Starter
Junior Member
Why does Visual Studio replace my message with something else?
Hi everyone
There is one thing I don't understand and I'm going crazy
When I try to display a long message with emoji and line breaks, Visual Studio deletes my message and replaces it with resources.GetString("MyMessage.Text")
For example I wrote this:
Code:
this.txtMessageLongOrder.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.txtMessageLongOrder.BackColor = System.Drawing.Color.Black;
this.txtMessageLongOrder.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.txtMessageOrder.ForeColor = System.Drawing.SystemColors.Menu;
this.txtMessageOrder.Location = new System.Drawing.Point(6, 19);
this.txtMessageOrder.Name = "txtMessageOrder";
this.txtMessageOrder.Size = new System.Drawing.Size(279, 504);
this.txtMessageOrder.TabIndex = 2;
this.txtMessageOrder.Text = "📈 Last name\n📈 First name\n📈 Age\n📈 Address\n📈 City\n📈 Zip code\n📈 Occupation\n📈 Hobbies\n📈 Eye color\n📈 Hair color \n📈 etc...\n📈 etc...";
Then Visual Studio turns it into:
Code:
this.txtMessageOrder.Text = resources.GetString("txtMessageOrder.Text");
I need to keep the message in plain text in the code so I can make changes...
Do you know what the problem is?
Thanks
-
May 6th, 2023, 02:52 PM
#2
Re: Why does Visual Studio replace my message with something else?
That looks likes C# code, not VB.Net. A VB.Net translation would look something like this:-
Code:
Dim sb As New System.Text.StringBuilder()
sb.AppendLine("📈 Last name")
sb.AppendLine("📈 First name")
sb.AppendLine("📈 Age")
sb.AppendLine("📈 Address")
sb.AppendLine("📈 City")
sb.AppendLine("📈 Zip code")
sb.AppendLine("📈 Occupation")
sb.AppendLine("📈 Hobbies")
sb.AppendLine("📈 Eye color")
sb.AppendLine("📈 Hair color")
sb.AppendLine("📈 etc...")
sb.AppendLine("📈 etc...")
Me.txtMessageLongOrder.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left)), System.Windows.Forms.AnchorStyles)
Me.txtMessageLongOrder.BackColor = System.Drawing.Color.Black
Me.txtMessageLongOrder.BorderStyle = System.Windows.Forms.BorderStyle.None
Me.txtMessageOrder.ForeColor = System.Drawing.SystemColors.Menu
Me.txtMessageOrder.Location = New System.Drawing.Point(6, 19)
Me.txtMessageOrder.Name = "txtMessageOrder"
Me.txtMessageOrder.Size = New System.Drawing.Size(279, 504)
Me.txtMessageOrder.TabIndex = 2
Me.txtMessageOrder.Text = sb.ToString()
-
May 6th, 2023, 04:19 PM
#3
Re: Why does Visual Studio replace my message with something else?
Yeah, it's C#, so I moved it.
My usual boring signature: Nothing
-
May 6th, 2023, 04:34 PM
#4
Re: Why does Visual Studio replace my message with something else?
Originally Posted by Sun2k
Hi everyone
There is one thing I don't understand and I'm going crazy
When I try to display a long message with emoji and line breaks, Visual Studio deletes my message and replaces it with resources.GetString("MyMessage.Text")
For example I wrote this:
Code:
this.txtMessageLongOrder.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.txtMessageLongOrder.BackColor = System.Drawing.Color.Black;
this.txtMessageLongOrder.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.txtMessageOrder.ForeColor = System.Drawing.SystemColors.Menu;
this.txtMessageOrder.Location = new System.Drawing.Point(6, 19);
this.txtMessageOrder.Name = "txtMessageOrder";
this.txtMessageOrder.Size = new System.Drawing.Size(279, 504);
this.txtMessageOrder.TabIndex = 2;
this.txtMessageOrder.Text = "📈 Last name\n📈 First name\n📈 Age\n📈 Address\n📈 City\n📈 Zip code\n📈 Occupation\n📈 Hobbies\n📈 Eye color\n📈 Hair color \n📈 etc...\n📈 etc...";
Then Visual Studio turns it into:
Code:
this.txtMessageOrder.Text = resources.GetString("txtMessageOrder.Text");
I need to keep the message in plain text in the code so I can make changes...
Do you know what the problem is?
Thanks
Firstly are you editing the auto generated designer file directly? If so then making changes via the designer can cause VS to overwrite your edits. Have you tried setting the text in the Form_Load event instead? That way it will be separate from the IDE generated code.
Does the form have the Localizable property set to true? That might be causing VS to change your code to use the resource file and replace your manual edits.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|