tags:

views:

71

answers:

2

hi i have written program in c# outlook where u can send ,receive ,reply ,forward ,the mails in text format through database i used gridview to retrieve the mails but the new task is how to mark the unread message as bold and read message as regular in text.

help needed

+1  A: 

You can loop through your rows by using.

DataGridViewCellStyle style = new DataGridViewCellStyle();
style.Font = new Font(dataGridView.Font, FontStyle.Bold);
foreach(DataGridViewRow dg_r in myDataGridView.rows) 
{
  dg_r.DefaultCellStyle = style; // sets Row Style to Bold
}
Henrik P. Hessel
The OP said GridView. The GridView is the Grid like control in ASP.NET not the DataGridView in Winforms.
BFree
I know. But afaik the syntax should be the same (just GridView instead of DataGridView)
Henrik P. Hessel
Actually, it doesn't have a collection of DataGridViewRows, rather it has GridViewRows, but more importantly than that, a GridViewRow doesn't have a DefaultCellStyle property. It has a Style collection which you can use to access the CSS attributes.
BFree
Yes, that's correct. But instead you can use: RowStyle and pass a TableItemStyle. Let's wait what he's using :)
Henrik P. Hessel
A: 

This may not be the direct answer to your question, but I think a better way to do this would be use a ListView. Then, you can use a DataTemplate for read items, and a different one for unread items. Then, just binding the set of mail items to this listview will cause the ListView to generate and display the UI for all the items. The main advantage of this will be that the UI will be virtualized, meaning UI items will be generated only as needed (when they scroll into view) and will be disposed automatically, keeping your UI responsive even when you have a huge number of items in the ListView.

You can then implement a DataTemplateSelector to pick between the two DataTemplates, based on some of the attributes of the mail items.

Tarydon