问题
I just wonder if anyone knows how to change the LineStyle of the Major and Minor grid for a ZedGraph?
For example I have:
graphPane.XAxis.MinorGrid.IsVisible = true;
I want something along this line:
graphPane.XAxis.MinorGrid.LineStyle => solid line.
I've done a lot of research today but could not find the answer.
Thank you in advance for your time.
回答1:
You probably have autoscaling set to true if you switch this off you can then set steps which you wish to use its best to stick with some numbers which are easily divisible otherwise you can get some strange numbers.
myPane.XAxis.Scale.MajorStepAuto = False
myPane.XAxis.Scale.MajorStep = 100
zg1.AxisChange()
zg1.refresh()
The above code is fully x-axis I'm fairly sure it will be similar to change the y-axis. I would start with a major axis and get the right first and you may find that the minor ones work well automatically.
The co code below is probably doing something very similar to what you're looking for and at the end of the case I've just switched on the XAxis.Scale.MajorStepAuto just in case we get some strange number
Select Case CDbl(maxNumber)
Case Is <= 100
myPane.XAxis.Scale.MajorStep = 10
Case Is <= 300
myPane.XAxis.Scale.MajorStep = 25
Case Is <= 1000
myPane.XAxis.Scale.MajorStep = 50
Case Is <= 5000
myPane.XAxis.Scale.MajorStep = 100
Case Is <= 10000
myPane.XAxis.Scale.MajorStep = 250
Case Is <= 50000
myPane.XAxis.Scale.MajorStep = 1000
Case Else
myPane.XAxis.Scale.MajorStepAuto = True
End Select
回答2:
The following will draw a you solid line in aqua for the major grid line
myPane.XAxis.MajorGrid.DashOff = 0
myPane.XAxis.MajorGrid.Color = Color.Aqua
Hope that helps
来源:https://stackoverflow.com/questions/35683563/zedgraph-majorgrid-and-minorgrid-linestyle