How to: Show Information from a Datasource Field in a Crosshair Cursor Label
- 2 minutes to read
This example demonstrates how to display information from the underlying datasource in the Crosshair Cursor label for every series point.
- Run Microsoft Visual Studio.
- Create a new Windows Forms Application or open an existing project.
- Drop the ChartControl onto the form.
- Add a Bar Series to the chart. Bind it to the Products table from the nwind.mdb database (see Lesson 3 - Bind Chart Series to Data for details on how to do this).
- Set the SeriesBase.ArgumentDataMember property to ProductName and SeriesBase.ValueDataMembers.Value to UnitPrice.
- Use the SeriesBase.CrosshairLabelPattern property to format the crosshair label’s content. You can enclose the datasource field names in braces instead of default placeholders. For example: “Unit price: {UnitPrice}”.
using System;
using System.Windows.Forms;
namespace CustomInfoInTooltips {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) {
// TODO: This line of code loads data into the 'nwindDataSet.Products' table. You can move or remove it.
this.productsTableAdapter.Fill(this.nwindDataSet.Products);
chartControl1.Series[0].CrosshairLabelPattern = "Unit price: {UnitPrice}\r\n" +
"Units in stock: {UnitsInStock}\r\n" +
"Quantity per unit: {QuantityPerUnit}";
}
}
}
Tip
A complete sample project is available in the DevExpress Code Examples database at https://supportcenter.devexpress.com/ticket/details/e126/how-to-show-a-tooltip-with-a-series-point-s-data.
See Also