问题
i am a beginner at c#, so you could help me. At first, i get some data from a RS422 to USB converter over a COM Port and now i want to display over the right COM-Port the graph on the Screen. My Question: How could i display the Graph on my WindowsForms ?
Sorry for my english.
M.Spitz
回答1:
There is a nice tool un Windows Forms called Chart. You can draw graphs of different kind with it.
Here is a Tutorial
Here is a Video that shows how to use it.
Here is a nice post with an example from StackOverflow.
Have fun exploring it.
Basically the steps are:
Create a Series for each line you want to draw.
Add the values from your array or list to the series.
EDIT: 3. See comment by TaW
EDIT 2) : here you find all different chart types that can be displayed.
and here how to use them.
When you click in the property window of the chart on Series
you get the Series-Properties. There you can also find the property: ChartType
and set it by a mouse click if you want to.
回答2:
You'll have to create the port object and set the necessary parameters for it from the design view search for port tool
or your code like this
dataPort.PortName = your_port_name;
dataPort.BaudRate = your_baud_rate;
After you open the port and read the data from it:
dataPort.Open();
while(dataPort.IsOpen)
{
chart1.Series["Series1"].Points.AddXY(val.Second, dataPort.ReadByte());
chart1.Update();
}
来源:https://stackoverflow.com/questions/38713649/how-could-i-display-a-graph-on-windowsforms