在ZedGraph窗格中,可以将CurveItem设置为"selected“。
zedGraphControl.GraphPane.CurveList[0].IsSelected = true;
zedGraphControl.Refresh();据我所知,这会将它的颜色更改为Color.Gray。
是否可以更改此选定状态颜色?
发布于 2012-08-09 15:30:47
我不知道这样的属性,但您可以通过手动重写ZedGraphControl的MouseClick事件并设置"selected“CurveItem的颜色来完成此操作,如下所示:
private void zedGraphControl1_MouseClick(object sender, MouseEventArgs e)
{
foreach (var curve in zedGraphControl1.GraphPane.CurveList)
{
curve.Color = Color.Black;
}
CurveItem nearestItem;
int nearestPoint;
zedGraphControl1.GraphPane.FindNearestPoint(e.Location, out nearestItem, out nearestPoint);
if (nearestItem != null)
{
nearestItem.Color = Color.Red;
}
zedGraphControl1.Refresh();
}更新:查看http://www.opensourcejavaphp.net/csharp/zedgraph/Line.cs.html和http://www.opensourcejavaphp.net/csharp/zedgraph/Selection.cs.html的源代码,Line.DrawCurve似乎使用了静态属性Selection.Line。如果不修改源代码,就很难改变这种行为。
Line.cs的一部分:
public void DrawCurve( Graphics g, GraphPane pane, CurveItem curve, float scaleFactor )
{
Line source = this;
if ( curve.IsSelected )
source = Selection.Line;Selection.cs:
/// The <see cref="Line" /> type to be used for drawing "selected"
/// <see cref="LineItem" /> and <see cref="StickItem" /> types
/// </summary>
public static Line Line = new Line( Color.Gray );发布于 2017-03-21 22:38:20
所选行是静态属性,但不是只读的。用户可以通过重置Selection.Line属性来更改格式:
public Form1()
{
InitializeComponent();
ZedGraph.Selection.Line.Width = 3;
ZedGraph.Selection.Line.Color = Color.Red;
...
}重置选择线后,所有选定的线都将按指定方式绘制。
https://stackoverflow.com/questions/11877965
复制相似问题