删除X轴的选定自定义标签 [英] To remove Selected Custom Labels of X axis

查看:73
本文介绍了删除X轴的选定自定义标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

      我正在使用Mschart绘制日线图,但是在Xaxis 需要在月末显示。

       I am using Mschart for plotting the line graph for day wise , but on Xaxis  need to show on month end dates .

示例2015年9月30日,2015年10月31日..

example 30-Sep-2015 ,31-Oct-2015 ..

我厌倦了使用

tmpChart.ChartAreas[tmpArea].AxisX.IntervalType = DateTimeIntervalType.Months;

但结果是01-Sep- 2015年,2015年10月1日...  而不是月结束日期。

but result was 01-Sep-2015 ,01-Oct-2015 ...   instead of end date of month.

稍后 我累了 删除 标签

Later  I tired to  remove the  labels




 List<CustomLabel> lstRemove = new List<CustomLabel>();
                DateTime Dt = new DateTime();
                int c = 0;
                foreach (CustomLabel lbl in Chart1.ChartAreas[0].AxisX.CustomLabels)
                {
                    Dt = Convert.ToDateTime(lbl.Text);

                    if (Dt.Day != DateTime.DaysInMonth(Dt.Year, Dt.Month))
                    {
                        lstRemove.Add(lbl);
                    }
                    else
                    {
                        lbl.RowIndex = c;
                        c++;
                    }

                    //        dp.Label = "";


                    //  lbl.Text = range[count];

                }
                foreach (CustomLabel lbl in lstRemove)
                    Chart1.ChartAreas[0].AxisX.CustomLabels.Remove(lbl);

当我调试  :删除后可以获得正确的数据。

When I debug  : proper data is available after remove .

但是, 在用户界面  标签不会被删除。

But,  in UI   labels are not removed .

请帮助...

推荐答案

你好,

为我的自定义标签将RowIndex设置为0。现在事情就好了。

干杯

Dinesh


这篇关于删除X轴的选定自定义标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆