473,385 Members | 2,015 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 1634

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Rxd | last post by:
I have a Datagrid that should have a couple of hidden columns. I used a DataGridTableStyle to hide the columns and it was working fine except I needed to prevent the DataGrid from allowing new rows...
2
by: Scott | last post by:
Hi all. A few days ago i ask this question and got a good quick response. I tried out what they said and it worked. However I have now come to try the same thing in another program and it...
2
by: Carlos | last post by:
Does DataGridTableStyle work in ASP.net ? any time I'm tring to define a varibale lke DataGridTableStyle MyStyle = new DataGridTableStyle(); it give me "The Type or name sapce...
2
by: kerpal | last post by:
Hi all, 1. Could anyone pls clarify the difference between setting the AlternatingBackColor property in DataGridTableStyle and in DataGrid?? 2. How come BackColor and AlternatingBackColor are...
2
by: Brett Romero | last post by:
I can't find what exactly I'm doing wrong that the following DataGridTableStyle is not working on my table. The result set returns 21 columns. I'm only formatting 5 via the TableStyle. I thought...
4
by: Brett Romero | last post by:
I have the following DataGridTableStyle: DataGridTableStyle gridTableStyle = new DataGridTableStyle(); gridTableStyle.MappingName = "myStyle"; DataGridTextBoxColumn dgsc = new...
3
by: nita | last post by:
I'm just starting out, and it's incredibly frustrating when I see sample code and then try to implement it. Case in point. I'm populating a collection then binding it to a datagrid. That works...
7
by: Mitchell S. Honnert | last post by:
Is there an equivalent of the DataGrid's DataGridTableStyle for the DataGridView? If not, is there an easy way to duplicate the DataGridTableStyle's functionality for the DataGridView? Here's...
0
by: Tommy152 | last post by:
I have a drop down box with a list of tables from a SQL CE database running on Windows Mobile 5, and once a user selects a table, all the data is bound to a datagrid. Now I'm trying to format the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.