Jump to content
Software FX Community

Problems with DataGrid headers


Recommended Posts

Hello guys,

Rly sry if u r alrdy bored by this subject, but i'm alrdy bored of trying to find a way not to show datagrid headers as datetime.tooadate() (as numbers, which look pretty cool as u can imagine :))) ) but to show them as actual dates, i mean.... humanly meaningful :)

please just dont tell me there is no workaround, other than c.DataGrid.ShowHeader = false

any kind of help will be deeply appreciated,

best regards & thx in advance


here is the code i used, if a test is required

using System;

using System.Collections.Generic;

using System.Data;

using System.Windows.Forms;

using ChartFX.WinForms;

namespace chart


public partial class dataTable : UserControl


public dataTable()



this._SetDefaultFieldUsage(maps, string.Empty, chart1);

chart1.ToolBar.Visible = true;



void __resetChart(Chart c)



c.Data.InterpolateHidden = true;

c.DataSourceSettings.Style |= DataSourceStyles.DatesAsLabels;

c.ToolBar.Visible = true;

c.DataGrid.Visible = true;

c.AxisX.DataFormat.Decimals = 10;

c.AxisX.LabelsFormat.Format = AxisFormat.DateTime;

c.AxisX.LabelsFormat.CustomFormat = "m/d/yy h:mm";

c.AxisY.DataFormat.Decimals = 10;


string[] maps = new string[] { "AVG_KN2", "DELTA_KN2", "HD_KN_BATCH2", "HD_KN_BATCH3" };

private void _SetDefaultFieldUsage(string[] distinctKNNames, string defaultKeyValueField, ChartFX.WinForms.Chart c)



FieldMap fm = null;

foreach (string s in distinctKNNames)


fm = new FieldMap(s, FieldUsage.Value);



c.DataSourceSettings.Fields.Add(new FieldMap("KNV_START_TIMESTAMP", FieldUsage.XValue));


private void _BindData()


DataTable t = new DataTable("tabeledData");

//reference for data to be inserted in the rows

object[] values;

t.Columns.Add("KNV_START_TIMESTAMP", typeof(DateTime));

IList<_DTDO> _list = _DTDO.GetCollectionOfData(40);

foreach (_DTDO kn in _list)


//fill the table

//create the columns

if (!t.Columns.Contains(kn.KND_NAME))

t.Columns.Add(kn.KND_NAME, kn.KNV_VALUE.GetType());

//create the array for inserting values

values = new object[t.Columns.Count];

values[0] = kn.KNV_START_TIMESTAMP;

int colNo = t.Columns.IndexOf(t.Columns[kn.KND_NAME]);

//create the values array

for (int i = 1; i < t.Columns.Count; i++)


//put on the kn col

if (i == colNo)

values = kn.KNV_VALUE;


values = null;


//insert data into table



//clear references

values = null;

chart1.DataSource = t;


#region unused

public class _DTDO


public string KND_NAME { get; set; }

public decimal KNV_VALUE { get; set; }

public DateTime KNV_START_TIMESTAMP { get; set; }

public static IList<_DTDO> GetCollectionOfData(int nrOfItems)


string[] nks = new string[] { "AVG_KN2", "DELTA_KN2", "HD_KN_BATCH2", "HD_KN_BATCH3" };

IList<_DTDO> toReturn = new _DTDO[nrOfItems];

_DTDO rec;

DateTime? dt = DateTime.Now;

Random r = new Random();

int rem = -1;

for (int i = 0; i < nrOfItems; i++)


rec = new _DTDO();

rem = i % 2;

// rem = i % 4;

rec.KND_NAME = nks[rem];

rec.KNV_VALUE = (decimal)(r.NextDouble() * 100);

rec.KNV_START_TIMESTAMP = (DateTime)(dt.Value.Add(new TimeSpan(00, i * 5, i * 10)));

toReturn = rec;


dt = null; r = null; rec = null;

return (IList<_DTDO>)toReturn;






Link to comment
Share on other sites

  • 3 weeks later...


Please try using the "XValuesAsHeaders" property. It instructs the chart to use XValues as the headers in the data editor. When set to true, the XValues passed to a chart will be used as point headers in the dataGrid. Please remember that in order for this property to affect the chart, the chart must include XValues (XY plot).chart1.DataGrid.XValuesAsHeaders = true;Regards,


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...