How do i add a custom visual element into a windows forms app project? (C#)

Me 141 Reputation points
2022-05-31T07:52:28.29+00:00

I want to add an element to my windows forms app with .NET 6.0. When i try following some tutorial, it doesnt work at all. Please help me.

I want to add FastColoredTextBox into my project, specifically.

Developer technologies C#
{count} votes

Accepted answer
  1. Castorix31 90,521 Reputation points
    2022-05-31T11:01:33.2+00:00

    You can just copy the sources from FastColoredTextBox
    (except FastColoredTextBox.csproj and FastColoredTextBox.resx)
    and it works with .NET 6

    A quick test =>

            FastColoredTextBox fctb = null;  
            private void Form1_Load(object sender, EventArgs e)  
            {  
                fctb = new FastColoredTextBox();  
                fctb.Location = new System.Drawing.Point(10, 10);  
                fctb.Size = new System.Drawing.Size(300, 300);  
                fctb.BorderStyle = BorderStyle.FixedSingle;  
                fctb.Language = Language.CSharp;  
                fctb.WordWrap = true;  
                fctb.WordWrapMode = WordWrapMode.CharWrapControlWidth;  
                fctb.Text = @"public Form1()  
    {  
          // Test comment  
          InitializeComponent();  
    }  
                ";  
                Controls.Add(fctb);  
            }  
    

    207072-net6-fastcoloredtextbox.jpg

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Karen Payne MVP 35,586 Reputation points Volunteer Moderator
    2022-05-31T09:52:32.19+00:00

    FastColoredTextBox is not compatible with any version of .NET Core which mean you can't use it in your project. I looked at the code, to make it work in your project would take hours of work which entails creating a new project, new forms and controls. Classes might port without changes.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.