Reason for toolbox items being greyed out [duplicate] - vb.net

I'm trying to add a chart to my Visual Studio form but the button is greyed out. I'm using .NET Framework 3.5 and C#. Following instructions online I've downloaded and installed the dll files from this link: http://www.microsoft.com/en-us/download/details.aspx?id=14422
I also added them as references and added the following line at the top of my form file:
using System.Windows.Forms.DataVisualization.Charting;
but the button is still greyed out.
What have I missed?

To make the chart control available, you need:
To be using .Net framework 4.0 or higher, OR for .Net framework 3.5 install this: http://www.microsoft.com/en-us/download/details.aspx?id=14422
On the toolbox context menu -> Choose Items... have the Chart control selected. (Sort by name in the Choose Toolbox Items dialog and scroll to Chart. There are two: one for Windows forms, one for Web forms. You need only select what's relevant.)
The chart control appears in the "Data" section of the Toolbox.
You do NOT need to any any "using" clause to the form source file, or any reference in the project references. (The reference is added automatically for you when you add the control.)

I too had this issue and could not resolve it for hours.
As posted here:
Visual Studio 2010 toolbox controls disabled or inactive
In order to solve it for me I just right-clicked one of the items in the toolbox, and chose "Reset Toolbox"
This resets the entire toolbox, so as mentioned in the answer above, all custom tools are lost and need to be re-imported.

Had the same problem.
What I did was to make sure that I was using the same Framework with the chart framework version.
During project creation, by default using .net 3.5. But since the chart is written for Framework 4.0, it will not work with 3.5.
You need to change the solution or project Framework to 4.0 or above by doing this:
On the menu bar of Visual Studio, click <your project name>/Properties.
Change target framework to 4.0 or above.
Save the properties setting.
Rebuild your solution.
After this, you may use that chart component.

Related

Unable to copy-paste Winforms controls from a form in a vb.net project to a form in a c# project

for a big refactoring project of about 140 forms I've been trying to copy and paste these controls through the designer. I'm using VS 2022 but I've also tried with 2019. The origin project is in .NET4.5 and the new project is in dotnet6. My machine is running on win10.
These are the things I've tried so far:
keyboard shortcuts ( ctrl-a + ctrl-c / ctrl-x + ctrl-v )
Drag 'n drop ( ctrl-a + drag + drop )
Same methods as above but one control at a time ( total size of clip is 164k bytes )
The paste option in the context menu of the c# form is grayed out and when I drag 'n drop I'm shown a "blocking" icon.
I'm at a loss and not about to redesign all these forms.
Am I missing something here?
I just did some testing and it appears that you cannot drag and drop - or copy and paste, presumably - between different instances of VS, which you appear to be trying to do. I opened the same solution twice and I was able to drag and drop between C# and VB projects in the same instance but I wasn't able to do so between two forms in the same VB project between instances.
This means that you will have to add one of the projects to the solution containing the other. That's not a big deal because adding an existing project to a solution doesn't move or copy that project. The solution simply refers to it in its existing location. Once you've done all the drag and drop, you can simply remove the project from the solution again and you're done.
According to this post, .NET framework 4.x is incompatible at the binary level with .NET core which prevents you from copying over controls. Logical really when I come to think about it.
I've tested with dotnet5.0 and dotnet6.0 both giving issues but dotnet4.8 works just fine.
As a solution to my problem I will try using an intermediate project in .NET framework 4.8 using c# and afterwards porting to dotnet6.
Thanks for the help.
You cannot directly copy control from .NET Framework 4.x to .NET6 in winform application, because .NET Framework and .NET6 are different frameworks, so if your project only targets windows, you can consider updating the project to .NET Framework 4.8 which allows you to copy-paste Winforms controls.
In order to convert VB project(.NET Framework) to C# project(.NET6), one of the option is to convert VB code in the InitializeComponent method to C#, and paste it into the same location in .NET 6.
Also check : Upgrade a Windows Forms App to .NET 6 with the .NET Upgrade Assistant
Note: some libraries in .NET Framework are not supported on .NET6, you may need to find their alternatives.

Charts and plots in .Net 4 using Windows Form

I am using Windows Form and .Net 4 in Visual Studio 2010. I need to do some cross-plots, and would like to have a few features, as cursor and zoom in and out.
I tried to use ZedGraph, however I was not able to add its controller to the toolbox. I don't know if I have done something wrong or if it is not compatible.
Do you have any suggestions?
Thank you!
First, I'll assume you are using WinForms (as opposed to WPF).
Add references to the ZedGraph DLLs to your project
Right-click references in the solution explorer and select Add Reference
Select the browse tab and locate ZedGraph.dll (also ZedGraph.Web.dll if needed)
Rebuild the project (F6)
In the Toolbox, check that ZedGraphControl has appeared under Components
This control can be added to the design layout of a form.
Alternatively, once you have the reference added, you can add a graph to a form in code with the following:
using ZedGraph;
ZedGraphControl myZedGraphControl = new ZedGraphControl();
// set size, location, etc. properties
form1.Controls.Add(myZedGraphControl);

Unable to use ObjectListView

I just downloaded ObjectListView. After adding the dll file when the objectListView is placed on my vb.net form it shows an error
Type 'BrightIdeasSoftware.ObjectListView' is not defined.
How to solve this problem ?
I am using VS2010
It sounds like you are missing a reference.
If you added the project source code, then you need to right-click on the project and select Add Reference..., select the Projects tab, and choose the ObjectListView project.
If you are just using the DLL, then you need to right-click on the project and select Add Reference..., select the Browse tab, and select the DLL file.
Update
Based on the screenshot, the issue is that ObjectListView requires the full .Net Framework, not the client profile.
To resolve this, right-click on the project, select Properties, then select .Net Framework 4 in the Target framework dropdown list (it will currently be set to .Net Framework 4 Client Profile).
I just downloaded the full demo package and verified that it would run. I then went to the Toolbox Right-Clicked and Selected Choose Items... under .Net Framework Components I then browsed to the folder that has the ObjectListView.dll in it and selected it. This added the component to the Containers group on the Toolbox. I then added ObjectListView to my form and it worked correctly. Check and make sure your project references have ObjectListView in them.
i.e.

Microsoft Chart Controls in Visual Studio 2010?

Is this possible? I installed them, but they don't appear. Do I have to import them or something?
If you cannot see the Chart control in the Toolbox, right click in the Toolbox, select Choose Items, and then select the following namespaces in the .NET Framekwork Components tab:
System.Web.UI.DataVisualization.Charting
System.Windows.Forms.DataVisualization.Charting
Please, take a look: How use MS chart control with VS 2010?
I haven't tried it with VS2010, but I would assume the process for using it is exactly the same as described there for other versions of VS. It won't appear in the tool box until you instal the add-ons
According to this blog post from January 2010:
The Microsoft Chart Control is available as separate installation for .NET Framework 3.5 and will be included in .NET Framework 4.0.
It could be that the controls haven't been updated to work with VS2010 because of this. If they're not in the Beta 2 by default (I don't have it installed on this machine to check) then it might be that they're only going to be included in the full release.
The Chart controls are included in version 4. Here's where you can find the types:
ASP.NET:
http://msdn.microsoft.com/en-us/library/system.web.ui.datavisualization.charting.aspx
Winforms:
http://msdn.microsoft.com/en-us/library/dd489065%28v=VS.100%29.aspx

Different style on buttons in messagebox in different projects

I have a problem with the style of the button in a messagebox.
If I call the following line of code in a current project the button get one type of visual apperance/style. And If I create a new VB.NET Windows Application project it gets a standard Windows apperance/style.
Windows.Forms.MessageBox.Show("Yaay", "Yaay!", Windows.Forms.MessageBoxButtons.OK)
See the difference between the buttons below.
I suspect they inherit the visual apperance from it's parent or maybe from some project settings. But I have not been able to find out from where.
Both projects are created in VB.NET 2.0, and both have same System.Windows.Forms - dll as reference (c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll).
http://www.freeimagehosting.net/uploads/2a956b0675.jpg
Screenshot can be found here.
Thanx in advance for your help!
I cannot see the image from where I am so I'm not sure if this will help you.
Open the Project Properties for each solution and look at the Application tab.
Is the "Enable Applicaton Framework" item ticked? And if so, is the "Enable XP Visual Styles" item also ticked?
That may the difference in the two solutions.