CalcIncrement
Posted: Wed Oct 18, 2006 7:07 pm
Using: VB 2005 (Express), TeeChart.NET 2.0.2456.16162
I am try to set up my application so the user can hit the . or / keys to scroll the bottom axis left or right an amount equal to one minor tick mark. My bottom axis has date and time info. Here is my code:
Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
'If TChart1.Focused Or Commander1.Focused Or LeftAutoScaleCheckBox.Focused Then
If TChart1.Focused Then
Select Case (keyData)
Case Keys.OemQuestion
TChart1.Axes.Bottom.Scroll(-TChart1.Axes.Bottom.CalcIncrement / TChart1.Axes.Bottom.MinorTickCount, False)
Case Keys.OemPeriod
TChart1.Axes.Bottom.Scroll(TChart1.Axes.Bottom.CalcIncrement / TChart1.Axes.Bottom.MinorTickCount, False)
End Select
End If
Return MyBase.ProcessCmdKey(msg, keyData)
End Function
It works OK on the first keystroke, but on the second or third I get an Unhandled Exception error with the following details:
************** Exception Text **************
System.ArgumentException: Parameter is not valid.
at System.Drawing.Graphics.MeasureCharacterRanges(String text, Font font, RectangleF layoutRect, StringFormat stringFormat)
at Steema.TeeChart.Drawing.Graphics3DGdiPlus.MeasureDisplayStringWidth(String text, Font font)
at Steema.TeeChart.Drawing.Graphics3DGdiPlus.MeasureString(ChartFont f, String text)
at Steema.TeeChart.Drawing.Graphics3D.TextWidth(String text)
at Steema.TeeChart.Chart.MultiLineTextWidth(String s, Int32& numLines)
at Steema.TeeChart.AxisLabels.InternalLabelSize(Double value, Boolean isWidth)
at Steema.TeeChart.AxisLabels.LabelWidth(Double value)
at Steema.TeeChart.Axis.get_CalcIncrement()
at Flocis_Visualizer.ChartForm.ProcessCmdKey(Message& msg, Keys keyData) in C:\Documents and Settings\jay\My Documents\Visual Studio 2005\Projects\Flocis Visualizer\Flocis Visualizer\ChartForm.vb:line 45
at System.Windows.Forms.Control.ProcessCmdKey(Message& msg, Keys keyData)
at System.Windows.Forms.Control.PreProcessMessage(Message& msg)
at System.Windows.Forms.Control.PreProcessControlMessageInternal(Control target, Message& msg)
at System.Windows.Forms.Application.ThreadContext.PreTranslateMessage(MSG& msg)
If I click the mouse on the chart control before each keystroke, I don't get the error. (Note: I added some additional code and I can see that the chart control is retaining focus, even when I haven't clicked it first.)
Am I doing something incorrectly? Or, is there another way to accomplish this without having to click on the chart before each keystroke?
Jay
I am try to set up my application so the user can hit the . or / keys to scroll the bottom axis left or right an amount equal to one minor tick mark. My bottom axis has date and time info. Here is my code:
Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
'If TChart1.Focused Or Commander1.Focused Or LeftAutoScaleCheckBox.Focused Then
If TChart1.Focused Then
Select Case (keyData)
Case Keys.OemQuestion
TChart1.Axes.Bottom.Scroll(-TChart1.Axes.Bottom.CalcIncrement / TChart1.Axes.Bottom.MinorTickCount, False)
Case Keys.OemPeriod
TChart1.Axes.Bottom.Scroll(TChart1.Axes.Bottom.CalcIncrement / TChart1.Axes.Bottom.MinorTickCount, False)
End Select
End If
Return MyBase.ProcessCmdKey(msg, keyData)
End Function
It works OK on the first keystroke, but on the second or third I get an Unhandled Exception error with the following details:
************** Exception Text **************
System.ArgumentException: Parameter is not valid.
at System.Drawing.Graphics.MeasureCharacterRanges(String text, Font font, RectangleF layoutRect, StringFormat stringFormat)
at Steema.TeeChart.Drawing.Graphics3DGdiPlus.MeasureDisplayStringWidth(String text, Font font)
at Steema.TeeChart.Drawing.Graphics3DGdiPlus.MeasureString(ChartFont f, String text)
at Steema.TeeChart.Drawing.Graphics3D.TextWidth(String text)
at Steema.TeeChart.Chart.MultiLineTextWidth(String s, Int32& numLines)
at Steema.TeeChart.AxisLabels.InternalLabelSize(Double value, Boolean isWidth)
at Steema.TeeChart.AxisLabels.LabelWidth(Double value)
at Steema.TeeChart.Axis.get_CalcIncrement()
at Flocis_Visualizer.ChartForm.ProcessCmdKey(Message& msg, Keys keyData) in C:\Documents and Settings\jay\My Documents\Visual Studio 2005\Projects\Flocis Visualizer\Flocis Visualizer\ChartForm.vb:line 45
at System.Windows.Forms.Control.ProcessCmdKey(Message& msg, Keys keyData)
at System.Windows.Forms.Control.PreProcessMessage(Message& msg)
at System.Windows.Forms.Control.PreProcessControlMessageInternal(Control target, Message& msg)
at System.Windows.Forms.Application.ThreadContext.PreTranslateMessage(MSG& msg)
If I click the mouse on the chart control before each keystroke, I don't get the error. (Note: I added some additional code and I can see that the chart control is retaining focus, even when I haven't clicked it first.)
Am I doing something incorrectly? Or, is there another way to accomplish this without having to click on the chart before each keystroke?
Jay