473,224 Members | 1,595 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,224 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 1624

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: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.