#VALX value in MS Chart in C# isn't coming in “M/d H:mm” format

半世苍凉 提交于 2019-12-08 01:56:45

问题


I wrote the following Winforms code:

chart1.ChartAreas[0].AxisX.LabelStyle.Format = "M/d H:mm ";

This makes my X-axis seen as, for example 11/25 8:00. But when I provide the tooltip for the datapoints it just provides the date and not the format "M/d H:mm". Here is my code:

chart1.Series[0].ToolTip = "Computer Name: #SERIESNAME \nDate & Time: #VALX  \nLevel: #VALY";` 

And the tooltip result which I got was this:

Computer Name: COMP NAME
Date & Time: 11/25/2013
Level: 4

I want the "Date & Time" value as " 11/25 8:00", which is being showed in the X-axis but not in the #VALX tooltip.


回答1:


Try this: #VALX{M/d H:mm}.
So your code will be:

chart1.Series[0].ToolTip = "Computer Name: #SERIESNAME \nDate & Time: #VALX{M/d H:mm}  \nLevel: #VALY";



回答2:


I think you should try LabelToolTip property instead of Tooltip, when dealing with data points, at least that's what documentation hints



来源:https://stackoverflow.com/questions/20211242/valx-value-in-ms-chart-in-c-sharp-isnt-coming-in-m-d-hmm-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!