0

I am currently working on a Windows Form application, and setting the text of labels in the InitializeComponent() method of MyForm.Designed.cs. I'm setting it to a function call so it looks like the first line, but it keeps getting reformatted into the second line. The first line works perfectly, it's just that it's getting reformatted.

this.teamGroup.Text = LocalizedLanguage.GetValue("SelectedTeamLabel");
this.teamGroup.Text = "Selected Team";

Additionally, this is also happening for the TabIndex as well.

I have:

  • C# 6.0
  • Visual Studio 2015 Community
  • ReSharper 10.0.2
jacobvoller.com
  • 476
  • 7
  • 28

2 Answers2

1

You can switch off automatic code formatting in VS under Options in Tools menu, selecting the Text Editor -> -> Formatting -> General page, and unchecking all the boxes there. You will still be able to manually format when all of the auto-formatting settings are turned off.

You can check the similar thing here link1 or link2

Community
  • 1
  • 1
sumngh
  • 566
  • 2
  • 10
0

Jacob, you shouldn't modify the code inside InitializeComponent manually.

/// <summary>
/// Required method for Designer support - do not modify
/// contents of this method with the code editor.
/// </summary>
private void InitializeComponent()

If you want to add something for the components use the following approach:

public YourForm ()
    {
        InitializeComponent();
        CustomInitializeComponent();
    }

    private void CustomInitializeComponent()
    {
        teamGroup.Text = LocalizedLanguage.GetValue("SelectedTeamLabel");
    }
Sergey_T
  • 538
  • 9
  • 14