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