I want to insert a textbox into a window form so I chose FastColoredTextbox(this). It's a user-control which can be used to make a textblock component that's very similar to the one in a text editor.
I've been trying to get it to work and have done everything I could with my limited knowledge (started winforms a few days ago)
After installing the NuGet package, I tried getting it to work but I am not even able to start. I need help getting started.
I checked if it had the relevant assembly reference and it did.
I expected a component like a button/label to appear in my toolbox which I could drag into my designer but it didn't, so I tried rebuilding and changed settings to see if it appeared in the toolbox as given here. I didn't see anything in the toolbox that I could drag and drop.
I downloaded a sample project and went through the code. The designer.cs file had the variable and code for the textbox. I modified and pasted it into my designer.cs file thinking that it would appear in my designer. Visual Studio gave me a warning that the changes I make in the designer appear here and I shouldn't directly edit it.
There's no documentation to display the textbox. There's documentation for syntax highlighting, code folding etc.
I tried googling "how to use custom user-components" and I got links detialing the process of making a custom component.
If you need anymore details please let me know.
Help is greatly appreciated :)
Since you are using a nuget package (Install-Package FCTB), the control is in this dll:
Solution Directory → packages → FCTB.2.16.11.0 → lib → FastColoredTextBox.dll
You can add the control to Toolbox and drop in on the form and simply assign some text to Text property of control.
To add the control to toolbox, just right click on a group in Toolbox and click Choose Items ..., then from .NET Framework Components tab use Browse... button to choose FastColoredTextBox.dll from this path:
Solution Directory → packages → FCTB.2.16.11.0 → lib → FastColoredTextBox.dll
After choosing the dll, press OK to add FastColoredTextBox control to the toolbox. Then simply drop an instance on form and in code, assign a text to it's Text property:
this.fastColoredTextBox1.Text = "Some Text";
Related
I have a Strange issue that I can't seem to fix, my Intellisense for XAML is no longer showing up and the code behind is only showing the premade Members. The Classes and Methods I have made are not showing up. Also Visual Studios is not recognizing other pages and wont recognize Navigation either.
I have tried going to Tools>Text Editor>C#>Intellisense -Statement completion and checking the boxes Auto list members and Parameter information. I also tried to clear out the cache.
From what I have researched it seems nobody else is having the same problems.
Close all open tabs in the project and quit VS, reopen the solution in VS and right click the XAML file in the Solution Explorer and then select Open With….> Source Code (Text) Editor.
Delete obj folder and clean project
Right click the XAML page>Properties>Build Action>change it to something else and back
Add a new content page under this specific project and check it works or not.
I would like to add that this worked for my .cs files only.
To get the XAML files Intellisense to work try to repeat the above steps on your .cs files or wait for the XAML files to gain Intellisense.
For ReSharper users: I found that having ReSharper's IntelliSense enabled for all languages can break Intellisense unexpectedly (especially for XAML files). Here's how I was able to fix the same problem that the asker had in Visual Studio 2017 with ReSharper installed:
In Visual Studio, go to the ReSharper menu and click on Options.
On the left side go to Environment > IntelliSense > General.
Select the Custom IntelliSense radio button.
Change any languages that have broken IntelliSense to Visual Studio (like XAML).
Click the Save button.
Just Exclude and Include Xaml Pages and It works again.
I solve that by changing the default editor in visual studio :
In Visual : File > Open
In the open file box : Select a .xaml file (don't open it)
Select "Open with" in the button arrow
Select "Source Code (Text) Editor and Set as Default
Click OK
I tried most of the above without much luck, but noticed if I created a new page, then intellisense worked as expected. For the properties section of the xaml file I noticed that the new page had a Custom Tool assigned (MSBuild:UpdateDesignTimeXaml) do I tried to cut-and-paste this into the existing forms without luck.
Looking at the .cs page for the new page that worked I notice that there is some extra info above the partial class [XamlCompilation(XamlCompilationOptions.Compile)] so I added this along with a using Xamarin.Forms.Xaml statement.
Finally I went back to the xaml properties page and selected Reset to Default for the Custom tool. Voila, for me everything started behaving itself.
Please add the following Nuget Package from Nuget Console.
Install-Package MobileEssentials.FormsIntellisense -Version 0.1.1-pre
You can download the latest update from the following link.
https://www.nuget.org/packages/MobileEssentials.FormsIntellisense/0.1.1-pre
After installing the package please restart the project and wait for sometime and check it.
Just delete .vs directory. this directory is hidden. so
Just Exclude and Include Xaml Pages worked for me too. The difference in .csproj file was:
MSBuild:Compile
now:
XamlIntelliSenseFileGenerator
I could fix the issue in VS2019 by launching the VS installer to modify it, un-check and check the workload ‘.NET desktop development’ to re-install it.
I've recently noticed that my ..LibraryTests project is not under source control:
When I try to do a checkin (by right clicking on the solution and pressing check in) it says that there are No Pending Changes. It's not seeing changes to the LibraryTests project because it is not under source control.
From my perspective:
The first project is under source control
The second project is not under source control
The solution itself does not seem to be under source control.
How do I get the entire solution including the Tests project checked in?
If you go into Source Control Explorer and navigate to your project you should see that LibraryTests isn't included. Right click on the folder, click on "Add items to folder..." then click on your project folder thats missing. Click next and this should add it to source control.
I have an existing library (not a Winforms application) that supplies some Winforms to a bona-fide Windows application. Within this library, I would like to create a User Control to group some controls together. To accomplish this, I right-clicked, Add, User Control and dragged some controls onto the new User Control.
So far, so good. The User Control even has the requisite User Control icon. But dragging the new User Control from the Solution Explorer to a new blank Winform does not work (I get a circle with a line through it), and dragging it over to the Toolbox doesn't work either (even though I get a + sign when I drag it over the Toolbox).
Is there some sort of XML magic or something else I'm missing to make this work?
Note: I had some problems with Visual Studio 2008 that I managed to fix by following the workarounds that can be found here. I am now able to get User Controls I added to my existing project into the toolbox by simply rebuilding the project.
Assuming I understand what you mean:
If your UserControl is in a library you can add this to you Toolbox using
Toolbox -> right click -> Choose Items -> Browse
Select your assembly with the UserControl.
If the UserControl is part of your project you only need to build the entire solution. After that, your UserControl should appear in the toolbox.
In general, it is not possible to add a Control from Solution Explorer, only from the Toolbox.
One way to get this error is trying to add a usercontrol to a form while the project is set to compile as x64. Visual Studio throws the unhelpful: "Failed to load toolbox item . It will be removed from the toolbox."
Workaround is to design with "Any CPU" and compile to x64 as necessary.
Reference: https://support.microsoft.com/en-us/kb/963017
I found that user controls can exist in the same project.
As others have mentioned, AutoToolboxPopulate must be set to True.
Create the desired user control.
Select Build Solution.
If the new user control doesn't show up in the toolbox, close/open Visual Studio.
If the user controls still aren't showing up in the toolbox, right click on the toolbox and select Reset Toolbox. Then select Build Solution. If they still aren't there, restart Visual Studio.
There must not be any build errors when the solution is built, otherwise new toolbox items will not be added to the toolbox.
One user control can't be applied to it ownself. So open another winform and the one will appear in the toolbox.
I made a usercontrol in my project, and after building project, I need to put it in my toolbox, and use it as a common control. but i can't. the UserControl is in my project namespace, and I tried Choose Item in right click menu, but I didn't find a way to add it.
I had problems getting them to add automatically to the toolbox as in VS2008/2005.
There's actually an option to stop the toolbox auto-populating!
Go to Tools > Options > Windows Forms Designer > General
At the bottom of the list, you'll find Toolbox > AutoToolboxPopulate which on a fresh install defaults to False. Set it true and then rebuild your solution.
Hey presto, the user controls in your solution should be automatically added to the toolbox.
You might have to reload the solution as well.
Right-click on toolbar then click on "choose item" in context menu. A dialog with registered components pops up. in this dialog click "Browse" to select your assembly with the usercontrol you want to use.
PS.
This assembly should be registered before.
I found that the user control must have a parameterless constructor or it won't show up in the list. at least that was true in vs2005.
Using VS 2010:
Let's say you have a Windows.Forms project. You add a UserControl (say MyControl) to the project, and design it all up. Now you want to add it to your toolbox.
As soon as the project is successfully built once, it will appear in your Framework Components. Right click the Toolbox to get the context menu, select "Choose Items...", and browse to the name of your control (MyControl) under the ".NET Framework Components" tab.
Advantage over using dlls: you can edit the controls in the same project as your form, and the form will build with the new controls. However, the control will only be avilable to this project.
Note: If the control has build errors, resolve them before moving on to the containing forms, or the designer has a heart attack.
I had many users controls but one refused to show in the Toolbox, even though I rebuilt the solution and it was checked in the Choose Items... dialog.
Solution:
From Solution Explorer I Right-Clicked the offending user control file and selected Exclude From Project
Rebuild the solution
Right-Click the user control and select Include in Project (assuming you have the Show All Files enabled in the Solution Explorer)
Note this also requires you have the AutoToolboxPopulate option enabled. As #DaveF answer suggests.
Alternate Solution: I'm not sure if this works, and I couldn't try it since I already resolved my issue, but if you unchecked the user control from the Choose Items... dialog, hit OK, then opened it back up and checked the user control. That might also work.
There are a couple of ways.
In your original Project, choose File|Export template
Then select ItemTemplate and follow the wizard.
Move your UserControl to a separate ClassLibrary (and fix namespaces etc).
Add a ref to the classlibrary from Projects that need it. Don't bother with the GAC or anything, just the DLL file.
I would not advice putting a UserControl in the normal ToolBox, but it can be done. See the answer from #Arseny
In my case, I couldn't see any of the controls in the project. Only when right clicking on toolBox and selecting "Show All" I saw them, but yet they were disabled...
Changing Project type from Windows application to ClassLibrary made the fix.
Basic qustion if you are using generics in your base control.
If yes:
lets say we have control:
public class MyComboDropDown : ComboDropDownComon<MyType>
{
public MyComboDropDown() { }
}
MyComboDropDown will not allow to open designer on it and will be not shown in Toolbox.
Why? Because base control is not already compiled - when MyComboDropDown is complied.
You can modify to this:
public class MyComboDropDown : MyComboDropDownBase
{
public MyComboDropDown() { }
}
public class MyComboDropDownBase : ComboDropDownComon<MyType>
{
}
Than after rebuild, and reset toolbox it should be able to see MyComboDropDown in designer and also in Toolbox
The issue with my designer was 32 vs 64 bit issue. I could add the control to tool box after following the instructions in Cannot add Controls from 64-bit Assemblies to the Toolbox or Use in Designers Within the Visual Studio IDE MS KB article.
Recompiling did the trick for me!
I just had this issue with VS 2022. There may be a quick/easy answer.
My quick and dirty user control would not appear in the toolbox (full rebuild etc.).
I quit the solutiuon and VS, reloaded all, rebuilt and it appeared and worked.
I'm trying to use the AutoCompleteBox control from the february release of WPFToolkit.
I install the toolkit using the .msi file, add the assembly reference, and only two new controls appears in my toolbox: Calendar and Datepicker.
I then tried to handcraft the XAML as shown in WPF: AutoComplete TextBox, ...again, but once again, the AutoCompleteBox is missing.
Also, since I've installed WPFToolkit, my toolbox has some strange behavior, like deleting all elements and not letting me add any new control.
Does anyone have had the same issues, and know how to solve them?
I had the same problem. You probably still need to add a reference to System.Windows.Controls.DataVisualization.Toolkit. That fixed it for me.
Try this:
Within VS right click on the Toolbox
Select "Reset Toolbox".
If that doesn't work:
Stop Visual Studio
Go to: <drive>:\Documents and Settings\<user>\Local Settings\Application Data\Microsoft\VisualStudio\<VS version>
Delete the hidden files:
toolbox.tbd
toolbox_reset.tbd
toolboxIndex.tbd
toolboxIndex_reset.tbd
Start Visual Studio