Charts and plots in .Net 4 using Windows Form - .net-4.0

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);

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.

What Windows Forms control would be used to create a dockable window like Visual Studio Solution Explorer?

I want to be able to use things like the Solution Explorer window or the Properties window from Visual Studio in my Windows Forms application. I am not sure what the term for it is so I cannot look it up.
Have you tried using a normal panel? You might want to code all the contents of the solution explorer and the properties panel. The panel can be docked from its properties. Then, for example, if autosize is disabled, you write
If ...... Then
_something_.Autosize = false
End If
But that's a TON of code!
I don't think you can reproduce the solution explorer dynamically nor the properties panel. Besides, do you need to change all properties of an object at once? It looks like you are trying to remake visual basic dynamically. Well, that can't happen. Not with the current versions of vb.net, at least.
You should try involving things with panel that appears on your screen with all the settings in it, but like TGamer, there is a lot of code to do. But start with showing and hiding the panel to start with. Maybe try importing the settings through a VS file stored somewhere in your directory.

Reason for toolbox items being greyed out [duplicate]

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.

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.

Can't see or add Website Data Sources in RDLC report in ASP.NET MVC

In the RDLC report, in Design view in Visual Studio 2008, we don't see anything in the Website Data Sources tab and the button to Add New Data Source is grayed out. Only the Refresh button is enabled, and clicking it doesn't do anything. Our business logic layer returns Lists of business objects and the business logic and business object projects are both referenced by the MVC project. This is an MVC app, so there is no App_Code folder.
How do we get our business objects to appear in the Website Data Sources list so we can drag and drop fields from the object onto our RDLC report?
I think I suffered the same problem as this.
I solved this by closing all open VS windows, cleaning, rebuilding the solution then adding a new WebForms page (yes I know its MVC) but it then seemed to trigger a refresh in something and the data sources showed up when we reopened and editted the rdlc file.
I have also been frustrated by this, using VB.NET, but this should fix it:
In addition to the reference to:
Microsoft.ReportViewer.Winforms or
Microsoft.ReportViewer.WebForms
You need to also add a reference to:
Microsoft.ReportViewer.Common
The Data Sources panel is still blank, but when you select Add Dataset, you'll see the correct options.
Try this...
https://msdn.microsoft.com/en-us/library/yft2c9ad.aspx
On the menu bar, choose View, Other Windows, Data Sources (or choose the Shift+Alt+D
I had the same problem in Visual Studio 2008. The solution I accidently found was to do the following:
1 - Launch VS 2008
2 - Open Solution
3 - Open report file (rdlc) and make sure "Website Data Sources" pane is showing
4 - Close VS 2008 (with the rdlc "having focus"
5 - Launch VS 2008
6 - Open Solution
You should now see the data in the Website Data Sources pane
One of the problems I had was that my DataSource class didn't have a parameterless constructor...after the parameterless constructor was added "the class" showed up in the DataSource list.
Small detail, but lost some time to figure it out. :)