Click here to Skip to main content
15,898,134 members
Home / Discussions / C#
   

C#

 
GeneralRe: "this" keyword Pin
Ron Beyer11-Sep-13 18:50
professionalRon Beyer11-Sep-13 18:50 
GeneralRe: "this" keyword Pin
Abhinav S11-Sep-13 18:23
Abhinav S11-Sep-13 18:23 
GeneralRe: "this" keyword Pin
V.11-Sep-13 21:49
professionalV.11-Sep-13 21:49 
QuestionDrawing a line that follows a moving point Pin
Davebandit11-Sep-13 4:40
Davebandit11-Sep-13 4:40 
AnswerRe: Drawing a line that follows a moving point Pin
Richard MacCutchan11-Sep-13 6:22
mveRichard MacCutchan11-Sep-13 6:22 
GeneralRe: Drawing a line that follows a moving point Pin
Davebandit11-Sep-13 8:28
Davebandit11-Sep-13 8:28 
GeneralRe: Drawing a line that follows a moving point Pin
Eddy Vluggen11-Sep-13 11:09
professionalEddy Vluggen11-Sep-13 11:09 
GeneralRe: Drawing a line that follows a moving point Pin
Davebandit12-Sep-13 1:04
Davebandit12-Sep-13 1:04 
GeneralRe: Drawing a line that follows a moving point Pin
Richard MacCutchan11-Sep-13 20:53
mveRichard MacCutchan11-Sep-13 20:53 
Questionnested classes Pin
Member 1026649411-Sep-13 1:51
Member 1026649411-Sep-13 1:51 
AnswerRe: nested classes Pin
Member 1026649411-Sep-13 2:00
Member 1026649411-Sep-13 2:00 
GeneralRe: nested classes Pin
Keith Barrow11-Sep-13 2:17
professionalKeith Barrow11-Sep-13 2:17 
GeneralRe: nested classes Pin
Member 1026649411-Sep-13 3:13
Member 1026649411-Sep-13 3:13 
GeneralRe: nested classes Pin
Dave Kreskowiak11-Sep-13 4:54
mveDave Kreskowiak11-Sep-13 4:54 
GeneralRe: nested classes Pin
NotPolitcallyCorrect11-Sep-13 2:41
NotPolitcallyCorrect11-Sep-13 2:41 
AnswerRe: nested classes Pin
V.11-Sep-13 3:20
professionalV.11-Sep-13 3:20 
AnswerRe: nested classes Pin
Richard MacCutchan11-Sep-13 6:19
mveRichard MacCutchan11-Sep-13 6:19 
QuestionHow can I solve thiss error : "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index" Pin
babak1411-Sep-13 1:33
babak1411-Sep-13 1:33 
AnswerRe: How can I solve thiss error : "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index" Pin
OriginalGriff11-Sep-13 2:31
mveOriginalGriff11-Sep-13 2:31 
AnswerRe: How can I solve thiss error : "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index" Pin
Keith Barrow11-Sep-13 2:40
professionalKeith Barrow11-Sep-13 2:40 
First, the value of i isn't doing anything according to your code, you should be able to remove it and use CellNo instead. Personally I'd move the declaration of CellNo inside the first foreach loop, that way you can also remove the line CellNo = 0; at the end.

int RowNo = 0;
C#
foreach (DataGridViewRow row in Firstdgv.Rows)
{
    int CellNo = 0;
    foreach (DataGridViewCell cell in row.Cells)
    {
        if (CellNo >= Finaldgv.Columns.Count)
            break;
        Finaldgv.Rows[RowNo].Cells[CellNo].Value = cell.Value;
        CellNo++;                  
    }
    RowNo++;
}



If this doesn't fix your problem (I doubt it will) you need to figure out which of the two indexes is wrong - you can put a breakpoint on, or you could temporarily amend Finaldgv.Rows[RowNo].Cells[CellNo].Value = cell.Value; to:

C#
var tempRow = Finaldgv.Rows[RowNo]
var tempCell = tempRow.Cells[CellNo]
tempCell.Value = cell.Value


And see which line breaks - my initial gut reaction is you have no rows.

GeneralRe: How can I solve thiss error : "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index" Pin
babak1411-Sep-13 5:27
babak1411-Sep-13 5:27 
GeneralRe: How can I solve thiss error : "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index" Pin
Pete O'Hanlon11-Sep-13 5:38
mvePete O'Hanlon11-Sep-13 5:38 
GeneralRe: How can I solve thiss error : "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index" Pin
babak1411-Sep-13 5:53
babak1411-Sep-13 5:53 
GeneralRe: How can I solve thiss error : "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index" Pin
Pete O'Hanlon11-Sep-13 6:31
mvePete O'Hanlon11-Sep-13 6:31 
GeneralRe: How can I solve thiss error : "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index" Pin
babak1411-Sep-13 7:25
babak1411-Sep-13 7:25 

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.