471,337 Members | 988 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

DataGridTableStyle does not apply to datagrid

Hi,
I have an ArrayList filled with many Alarm object ( i will ad next this
class definition). I use this arraylist as a datasource for my datagrid.
I want to apply some table style, but it does not work at all.

this is my code :

first, the alarm class.
class Alarm

{

private int indexAlarmeEvent;

private bool acked;

private DateTime dateCreate;

private DateTime dateAck;

private string lib1;

private string lib2;

private string lib3;

private int alarmGroup;

private int alarmPriority;

private int userLevelAck;

private Color colorBackground;

private Color colorTextAlarmActive;

private Color colorTextAlarmWhite;

public int IndexAlarmeEvent{get{return
indexAlarmeEvent;}set{indexAlarmeEvent = value;}}

public DateTime DateCreate{get{return dateCreate;}set{dateCreate = value;}}

public string Lib1{get {return lib1;}set{lib1 = value;}}

public int AlarmGroup { get { return alarmGroup; } set { alarmGroup =
value; } }

public int AlarmPriority { get { return alarmPriority; } set { alarmPriority
= value; } }

}

then my code concerning the datagrid

public void UpdateDatagrid(ArrayList List)

{

this.dataGrid1.DataSource = List;

DataGridTableStyle ts = new DataGridTableStyle();

ts.MappingName = "List";

DataGridTextBoxColumn cs = new DataGridTextBoxColumn();

cs.MappingName = "IndexAlarmeEvent";

cs.HeaderText = "N°";

cs.Format = "d";

cs.Width = 10;

ts.GridColumnStyles.Add(cs);
cs = new DataGridTextBoxColumn();

cs.MappingName = "DateCreate";

cs.HeaderText = "Date";

cs.Format = "g";

cs.Width = 60;

ts.GridColumnStyles.Add(cs);

cs = new DataGridTextBoxColumn();

cs.MappingName ="AlarmGroup";

cs.HeaderText ="Groupe";

cs.Format = "d";

cs.Width = 10;

ts.GridColumnStyles.Add(cs);

cs = new DataGridTextBoxColumn();

cs.MappingName = "Lib1";

cs.HeaderText = "Libellé";

// cs.Format = ""; // ??? what should i use here for a byte array
representing a string ?

cs.Width = 130;

ts.GridColumnStyles.Add(cs);

cs = new DataGridTextBoxColumn();

cs.MappingName = "AlarmPriority";

cs.HeaderText = "Priorité";

cs.Format = "d";

cs.Width = 10;

ts.GridColumnStyles.Add(cs);

// Add the custom tablestyle to the DataGrid

dataGrid1.TableStyles.Clear();

dataGrid1.TableStyles.Add(ts);

this.dataGrid1.Refresh();

}

So what is wrong ?

I can see that my datagrid is populated, but the specified style are not
applied.

regards,

Guillaume
Jun 22 '07 #1
0 1532

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Scott | last post: by
2 posts views Thread by Carlos | last post: by
2 posts views Thread by Brett Romero | last post: by
4 posts views Thread by Brett Romero | last post: by
3 posts views Thread by nita | last post: by
7 posts views Thread by Mitchell S. Honnert | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.