Click here to Skip to main content
15,900,461 members
Home / Discussions / C#
   

C#

 
AnswerRe: Property PinPopular
Pete O'Hanlon10-May-11 20:39
mvePete O'Hanlon10-May-11 20:39 
AnswerRe: Property Pin
Luc Pattyn11-May-11 0:34
sitebuilderLuc Pattyn11-May-11 0:34 
AnswerRe: Property Pin
Joshi, Rushikesh11-May-11 2:29
professionalJoshi, Rushikesh11-May-11 2:29 
AnswerRe: Property Pin
Amarnath S12-May-11 17:55
professionalAmarnath S12-May-11 17:55 
QuestionChanging values in DataTable.. [modified] Pin
siva45510-May-11 19:20
siva45510-May-11 19:20 
AnswerRe: Changing values in DataTable.. Pin
dan!sh 10-May-11 19:22
professional dan!sh 10-May-11 19:22 
AnswerRe: Changing values in DataTable.. Pin
Hiren solanki10-May-11 21:07
Hiren solanki10-May-11 21:07 
AnswerRe: Changing values in DataTable.. Pin
Luc Pattyn11-May-11 0:44
sitebuilderLuc Pattyn11-May-11 0:44 
Here are two suggestions:

1.
Each column of a DGV has a default style which you can alter; here is a typical statement doing that:
dgvArticles.Columns[DGVA_COL_BOOKMARKS].DefaultCellStyle.Format="#,###"; 

This would set the style of all data cells in one column, it probably is what you want.
For numbers you can specify different styles for positive, negative and zero values.

2.
Every time a cell is going to be recalculated for later painting, a DGV cell fires its CellFormatting event. You can assign a handler, that determines the style to be used at run-time, and this for individual cells. Here is another (partial) example:
private void dgvUsers_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) {
    if (e.RowIndex...) {
        if (e.ColumnIndex...) {
            e.CellStyle.BackColor=Color.Gold;
        }
    }
}


FYI: both examples were inspired by actual code inside my "CP Vanity" article.

BTW: the above is NOT changing the value in the cells, it is only changing the way the cell content looks.

Smile | :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

QuestionMSTest Pin
Subin Mavunkal10-May-11 19:14
Subin Mavunkal10-May-11 19:14 
AnswerRe: MSTest Pin
dan!sh 10-May-11 19:20
professional dan!sh 10-May-11 19:20 
GeneralRe: MSTest Pin
Subin Mavunkal10-May-11 19:25
Subin Mavunkal10-May-11 19:25 
GeneralRe: MSTest Pin
dan!sh 10-May-11 21:48
professional dan!sh 10-May-11 21:48 
AnswerRe: MSTest Pin
Dalek Dave18-May-11 12:17
professionalDalek Dave18-May-11 12:17 
QuestionAdding service to c# windows application Pin
sarang_k10-May-11 19:12
sarang_k10-May-11 19:12 
AnswerRe: Adding service to c# windows application Pin
dan!sh 10-May-11 19:20
professional dan!sh 10-May-11 19:20 
GeneralRe: Adding service to c# windows application Pin
sarang_k10-May-11 19:22
sarang_k10-May-11 19:22 
GeneralRe: Adding service to c# windows application Pin
dan!sh 10-May-11 21:54
professional dan!sh 10-May-11 21:54 
GeneralRe: Adding service to c# windows application Pin
Joshi, Rushikesh11-May-11 3:17
professionalJoshi, Rushikesh11-May-11 3:17 
QuestionDataGridView Sorting in windows Pin
siva45510-May-11 17:03
siva45510-May-11 17:03 
AnswerRe: DataGridView Sorting in windows [modified] Pin
Luc Pattyn10-May-11 17:11
sitebuilderLuc Pattyn10-May-11 17:11 
Questionget real html code from webbrowser Pin
mabrahao10-May-11 11:15
mabrahao10-May-11 11:15 
AnswerRe: get real html code from webbrowser Pin
Luc Pattyn10-May-11 11:22
sitebuilderLuc Pattyn10-May-11 11:22 
GeneralRe: get real html code from webbrowser Pin
mabrahao10-May-11 11:33
mabrahao10-May-11 11:33 
AnswerRe: get real html code from webbrowser Pin
Luc Pattyn10-May-11 11:44
sitebuilderLuc Pattyn10-May-11 11:44 
GeneralRe: get real html code from webbrowser Pin
mabrahao10-May-11 11:49
mabrahao10-May-11 11:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.