ocaccy
asked on
C# - Using var in Chart Control with values. Concatenates string with integers in var.
Hi everyone.
How to use var for the model below?
Thanks in advance, ocaccy
How to use var for the model below?
Thanks in advance, ocaccy
var ch1=this.chart1.ChartAreas[0];
switch(x)
{
case 1:
var chInt=7200D;
ch1.AxisX.LabelStyle.Interval=chInt;
ch1.AxisX.MajorGrid.Interval=chInt;
ch1.AxisX.MajorTickMark.Interval=chInt;
break;
case 2:
var chInt=14400D;
ch1.AxisX.LabelStyle.Interval=chInt;
ch1.AxisX.MajorGrid.Interval=chInt;
ch1.AxisX.MajorTickMark.Interval=chInt;
break;
case 3:
var chInt=21600D;
ch1.AxisX.LabelStyle.Interval=chInt;
ch1.AxisX.MajorGrid.Interval=chInt;
ch1.AxisX.MajorTickMark.Interval=chInt;
break;
}
var ch1=this.chart1.ChartAreas[0];
int i_ch1Y=7200;
switch(x)
{
case 1:
i_chInt=x*i_ch1Y;
var chInt=i_chInt+"D";
// This is my idea, but I don't know how to concatenate
// int value to String D to turn into 7200D.
ch1.AxisX.LabelStyle.Interval=chInt;
ch1.AxisX.MajorGrid.Interval=chInt;
ch1.AxisX.MajorTickMark.Interval=chInt;
break;
case 2:
i_chInt=x*i_ch1Y;
var chInt=i_chInt+"D";
ch1.AxisX.LabelStyle.Interval=chInt;
ch1.AxisX.MajorGrid.Interval=chInt;
ch1.AxisX.MajorTickMark.Interval=chInt;
break;
case 3:
i_chInt=x*i_ch1Y;
var chInt=i_chInt+"D";
ch1.AxisX.LabelStyle.Interval=chInt;
ch1.AxisX.MajorGrid.Interval=chInt;
ch1.AxisX.MajorTickMark.Interval=chInt;
break;
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Does not work, because it is expected to double.
chart1.ChartAreas[0].AxisX .LabelStyl e.Interval =7200D;
chart1.ChartAreas[0].AxisX .MajorGrid .Interval= 7200D;
chart1.ChartAreas[0].AxisX .MajorTick Mark.Inter val=7200D;
If use this:
var chInt = 7200D;
chart1.ChartAreas[0].AxisX .MajorTick Mark.Inter val=chInt;
works.
chart1.ChartAreas[0].AxisX
chart1.ChartAreas[0].AxisX
chart1.ChartAreas[0].AxisX
If use this:
var chInt = 7200D;
chart1.ChartAreas[0].AxisX
works.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you.
ASKER
int aa;
int xx=2;
int yy=7200;
aa=xx*yy;
var chInt=aa+"D"; // How to concatenate this ( aa+"D" ) to turn it ( 14400D ) ?
sample:
ch1.AxisX.LabelStyle.Inter