这个示例展示了在运行时刻如何访问 轴标题

要这样做,则把 图象 对象转换为所需的图象类型,以便于访问它的 。 然后,就可以访问 Axis2D.Title 属性。

C#CopyCode image复制代码
// Cast the chart's diagram to the XYDiagram type, to access its axes.
XYDiagram diagram = (XYDiagram)chartControl1.Diagram;

// Customize the appearance of the X-axis title.
diagram.AxisX.Title.Visible = true;
diagram.AxisX.Title.Alignment = StringAlignment.Center;
diagram.AxisX.Title.Text = "X-axis Title";
diagram.AxisX.Title.TextColor = Color.Red;
diagram.AxisX.Title.Antialiasing = true;
diagram.AxisX.Title.Font = new Font("Tahoma", 14, FontStyle.Bold);

// Customize the appearance of the Y-axis title.
diagram.AxisY.Title.Visible = true;
diagram.AxisY.Title.Alignment = StringAlignment.Center;
diagram.AxisY.Title.Text = "Y-axis Title";
diagram.AxisY.Title.TextColor = Color.Blue;
diagram.AxisY.Title.Antialiasing = true;
diagram.AxisY.Title.Font = new Font("Tahoma", 14, FontStyle.Bold);
Visual BasicCopyCode image复制代码
' Cast the chart's diagram to the XYDiagram type, to access its axes.
Dim diagram As XYDiagram = CType(chartControl1.Diagram, XYDiagram)

' Customize the appearance of the X-axis title.
diagram.AxisX.Title.Visible = True
diagram.AxisX.Title.Alignment = StringAlignment.Center
diagram.AxisX.Title.Text = "X-axis Title"
diagram.AxisX.Title.TextColor = Color.Red
diagram.AxisX.Title.Antialiasing = True
diagram.AxisX.Title.Font = New Font("Tahoma", 14, FontStyle.Bold)

' Customize the appearance of the Y-axis title.
diagram.AxisY.Title.Visible = True
diagram.AxisY.Title.Alignment = StringAlignment.Center
diagram.AxisY.Title.Text = "Y-axis Title"
diagram.AxisY.Title.TextColor = Color.Blue
diagram.AxisY.Title.Antialiasing = True
diagram.AxisY.Title.Font = New Font("Tahoma", 14, FontStyle.Bold)

在下面的插图中显示了结果。

CodeCentralShow Me

在 DevExpress Code Central 数据库中可以找到完整的示例项目,网址是 http://www.devexpress.com/example=E1366。 取决于目标平台类型 (ASP.NET、WinForms 等),可以在线运行本示例,或者下载自动可执行的示例。

Expand image参阅