I have created a user control with a TextBox and two Buttons, but I haven't created events, just I place them to user control. When I want to add the user control to my form it says:
Cannot move Task_control.cs. The destination folder is the same as the source folder.
I can't understand why.
After creating your user control, you should build the project (F6 or Ctrl+Shift+B).
Then Visual Studio automatically adds the control to the Toolbox. You should drag the control from the Toolbox (Ctrl+Alt+X) to the form.
If after successfully building the project, the control is not on the Toolbox, make sure that you have Automatically Populate Toolbox set to true: Go to Tools->Options, select Windows Forms Designer node, and set Automatically Populate Toolbox to true.
You can also manually add your user control to the toolbox (if "Automatically Populate Toolbox" is not set, and you don't want to set it!). It is highly recommended that you create an additional Tab on the Toolbox for your specific user controls: Right click on an empty area of the Toolbox and click Add Tab, then give the new tab a name.
Now build the project, right click on an empty area on the toolbox (of course, in tab you already created, or in the "General" tab), and select Choose Items:
Wait a few seconds (or minutes) for the dialog to be ready, then click Browse and select your assembly. All of your user controls are now in the list. Select the ones you want to add to the Toolbox and click OK.
After creating your user control, you should build the project from the Solution Explorer. Click on your project name and click build, If it doesn't work rebuild it again enter image description here
Related
When recording CUIT in Visual Studio 2015 (C#), I click inside a WinRow (inside a property grid-view table) which enables the ellipse [...] button control to click and open a pop-up window. However, the button is only visible when the WinRow is selected. So on playback, the WinRow loses focus between steps and the button is no longer visible to be clicked.
Does anyone know how to keep the focus inside the WinRow to be able to see/click the button?
Well if the WinRow is defined in your UIMAp Designer file, then you should add a clik on it just before the click on the button to put again the focus on the Winrow first.
But you will have to handcode it in external cs file because any modification on the UIMap designer will be automatically removed at it first next update...
Note that a lot of recorded actions may not replay properly, mostly when you are in a dynamic behavior context, so you may have to handcode your automatisation to playback each needed actions.
So, I just installed dotConnect and in the wpf editor, if I select say a button then click and drag it to the window under construction in the designer, the option to select another control already there is lost. After that every time I click in the designer window it will place another button instead of highlighting the component or simply the last item I click and drag.
It's as if the toolbox is not letting go of my mouse function. I'm not sure if the dotConnect is related or not but it is the last change I made to VS since it started.
Has anyone dealt with this and know how to fix it?
Edit:
I found that if I click and drag from the toolbox to a restricted area (for instance the solution explorer) and drop it, it returns to normal. I have to do this every time I click and drag a new control into the design window.
After the update as TrevorBrooks suggested, the problem went away.
I have several Visual Studio 2003 c# projects, each of them containing a "User Control" item where I read some input data from text boxes, perform some calculations when a button is clicked and display the results in text boxes. The outputs of these projects are dll files.
The thing is I would like to create a separate project with a TabControl item and add the "User Control" items from my existing projects as TabPages. It is important to keep intact the existing event handlers of my "User Control" items. The output of the resulting project should also be a dll file. How do I do it?
Maybe somebody knows a different way to obtain the same result?
Thank you very much!
Peter
If this is a winforms application, then you need to take a couple of steps:
1) Add references to each of the UserControl project DLLs to your application.
2) Add the controls to your tab pages. There are two options:
a) Add the control through code at run time.
b) Add the control to the form at design time (I prefer this method, but both are correct). To do this: open the form that you want to place the controls on, open the toolbox, if it isn't already, then drag each of the project DLLs onto the toolbox. This should create items in the toolbox to chose from that match your usercontrols. Create a tab for each user control, then drag the appropriate item from the toolbar to the tab; this should create the user control in the tab.
I have a class in an external library subclassing UserControl and set to public. Now I want to use this usercontrol in my main WinForms app. I have added this external library to the references of the main app, but the user control haven't appeard in the Toolbox - I have been told it should appear.
I am doing this for the first time. So, sorry if my question is too trivial.
Right click on the title panel, in the Toolbox, where you want the control.
Select Choose Items...
Click the Browse... button on the .NET Framework Components tab in the dialog that pops up (might take a few seconds for it to show)
Navigate to the external library, select the file and click Open.
All public controls from that library are now available for selection.
You can right click on your toolbox and add it from the context menu...
You can add items to the toolbox by right-clicking on it, "Choose Items...". Then go and get a coffee - it takes ages to load. Locate your dll.
Note that adding an item from the toolbox will automatically add the reference to the project.
Look under Tools->Options, navigate to Windows Forms Designer->General, and make sure "AutoToolboxPopulate" is set to true.
That's for VS 2008, but it should be in a similar place on earlier versions.
Note: I believe this may only work for your own projects. If it's referencing a compiled DLL, it may not get the controls from the DLL.
This is in reference to my other question Auto Clearing Textbox.
If I choose to derive a new TextBox control from TextBox instead of implement a user control just containing my Textbox, how would I include that in the toolbox.
Right-click the toolbox, click "Choose
Items" from the context menu, browse
to your DLL, and select it.
To extend on Greg's answer...
Just to clarify, you cannot add a user control to the tool box if the code for it is in the same project that you want to use it in. For some reason MS has never added this ability, which would make sense since we don't want to always have to create a User Control Library DLL everytime we want to use a user control. So, to get it in your tool box, you have to first create a separate "User Control Library" project (which can be in the same solution!) and then do what Greg said.
Right-click the toolbox, click "Choose Items" from the context menu, browse to your DLL, and select it.