Click here to Skip to main content
15,888,454 members
Home / Discussions / C#
   

C#

 
AnswerRe: Running a method on a seperate thread [modified] Pin
Luc Pattyn2-Oct-10 3:51
sitebuilderLuc Pattyn2-Oct-10 3:51 
GeneralRe: Running a method on a seperate thread Pin
teknolog1232-Oct-10 13:37
teknolog1232-Oct-10 13:37 
AnswerRe: Running a method on a seperate thread Pin
Luc Pattyn2-Oct-10 14:17
sitebuilderLuc Pattyn2-Oct-10 14:17 
GeneralRe: Running a method on a seperate thread Pin
teknolog1233-Oct-10 5:11
teknolog1233-Oct-10 5:11 
GeneralRe: Running a method on a seperate thread Pin
Luc Pattyn3-Oct-10 5:18
sitebuilderLuc Pattyn3-Oct-10 5:18 
QuestionVisual diff of 2 DataTables Pin
Aaron D Anderson1-Oct-10 20:47
Aaron D Anderson1-Oct-10 20:47 
AnswerRe: Visual diff of 2 DataTables Pin
Luc Pattyn2-Oct-10 4:10
sitebuilderLuc Pattyn2-Oct-10 4:10 
AnswerRe: Visual diff of 2 DataTables Pin
PIEBALDconsult2-Oct-10 15:48
mvePIEBALDconsult2-Oct-10 15:48 
I did something similar a few weeks back, except comparing text entered in a TextBox to rows in a DGV ( Dead | X| ).
Likewise, I'm setting cell backgrounds to red, green, or yellow as appropriate.
A quick search showed me the CellFormatting event technique, but it didn't perform as required.

Eventually I resorted to not setting the DataSource, but adding the rows one at a time and setting the cell's background color.

Here's the code; the source rows are in a DataTable, the last column contains DataGridViewButtonCells that will perform an Insert, Update, or Delete as appropriate and has the desired background color.

public void
PopulateGrid
(
)
{
    foreach
    (
        System.Data.DataRow src
    in
        this.TableDef.DataTable.Rows
    )
    {
        System.Windows.Forms.DataGridViewButtonCell action =
            (System.Windows.Forms.DataGridViewButtonCell) src [ this.dgvData.Columns.Count - 1 ] ;

        System.Windows.Forms.DataGridViewRow dst =
            new System.Windows.Forms.DataGridViewRow() ;

        for ( int c = 0 ; c < this.dgvData.Columns.Count - 1 ; c++ )
        {
            System.Windows.Forms.DataGridViewTextBoxCell cell =
                new System.Windows.Forms.DataGridViewTextBoxCell() ;

            cell.Value = src [ c ] ;

            cell.Style.BackColor = action.Style.BackColor ;

            dst.Cells.Add ( cell ) ;
        }

        dst.Cells.Add ( action ) ;

        this.AddGridRow ( dst ) ;
    }

    return ;
}



P.S. If you're wondering about AddGridRow... it's an anonymous method to add the row to the DGV because I'm running on a thread. You are too, right? Right?

this.AddGridRow = delegate
(
    System.Windows.Forms.DataGridViewRow Row
)
{
    if ( this.InvokeRequired )
    {
        this.Invoke ( this.AddGridRow , Row ) ;
    }
    else
    {
        this.dgvData.Rows.Add ( Row ) ;
    }

    return ;
} ;

QuestionDebug Break Pin
Richard Andrew x641-Oct-10 7:51
professionalRichard Andrew x641-Oct-10 7:51 
AnswerRe: Debug Break Pin
OriginalGriff1-Oct-10 8:16
mveOriginalGriff1-Oct-10 8:16 
GeneralRe: Debug Break Pin
Richard Andrew x641-Oct-10 8:22
professionalRichard Andrew x641-Oct-10 8:22 
GeneralRe: Debug Break Pin
OriginalGriff1-Oct-10 8:30
mveOriginalGriff1-Oct-10 8:30 
AnswerRe: Debug Break Pin
Abhinav S1-Oct-10 18:08
Abhinav S1-Oct-10 18:08 
QuestionDecoding non-ascii characters Pin
Chriso821-Oct-10 1:58
Chriso821-Oct-10 1:58 
AnswerRe: Decoding non-ascii characters Pin
Luc Pattyn1-Oct-10 2:10
sitebuilderLuc Pattyn1-Oct-10 2:10 
AnswerRe: Decoding non-ascii characters Pin
Chriso821-Oct-10 3:51
Chriso821-Oct-10 3:51 
GeneralRe: Decoding non-ascii characters Pin
Luc Pattyn1-Oct-10 4:47
sitebuilderLuc Pattyn1-Oct-10 4:47 
Questionhow to program cash drawer? Pin
Syed Shahid Hussain1-Oct-10 0:26
Syed Shahid Hussain1-Oct-10 0:26 
AnswerRe: how to program cash drawer? PinPopular
OriginalGriff1-Oct-10 0:34
mveOriginalGriff1-Oct-10 0:34 
JokeRe: how to program cash drawer? Pin
Sauro Viti1-Oct-10 0:51
professionalSauro Viti1-Oct-10 0:51 
GeneralRe: how to program cash drawer? Pin
OriginalGriff1-Oct-10 0:56
mveOriginalGriff1-Oct-10 0:56 
AnswerRe: how to program cash drawer? Pin
Luc Pattyn1-Oct-10 1:04
sitebuilderLuc Pattyn1-Oct-10 1:04 
AnswerRe: how to program cash drawer? Pin
PIEBALDconsult1-Oct-10 3:10
mvePIEBALDconsult1-Oct-10 3:10 
AnswerRe: how to program cash drawer? Pin
Chris Trelawny-Ross1-Oct-10 5:08
Chris Trelawny-Ross1-Oct-10 5:08 
GeneralRe: how to program cash drawer? Pin
Syed Shahid Hussain1-Oct-10 5:09
Syed Shahid Hussain1-Oct-10 5:09 

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.