Re: Foreach with DataGrid
From: Dmitriy Lapshin [C# / .NET MVP] (x-code_at_no-spam-please.hotpop.com)
Date: 07/08/04
- Next message: morphius: "Function Implementation"
- Previous message: Tamir Khason: "Re: Create DSN"
- In reply to: Gidi: "Re: Foreach with DataGrid"
- Next in thread: Scott Allen: "Re: Foreach with DataGrid"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 8 Jul 2004 19:04:11 +0300
Gidi,
I am not sure you can iterate on rows... , but you can easily access cells!
Here's an example from MSDN which does just what you need:
private void PrintCellValues(DataGrid myGrid){
int iRow;
int iCol;
DataTable myTable;
// Assumes the DataGrid is bound to a DataTable.
myTable = (DataTable) dataGrid1.DataSource;
for(iRow = 0;iRow < myTable.Rows.Count ;iRow++) {
for(iCol = 0;iCol < myTable.Columns.Count ;iCol++) {
Console.WriteLine(myGrid[iRow, iCol]);
}
}
}
-- Sincerely, Dmitriy Lapshin [C# / .NET MVP] Bring the power of unit testing to the VS .NET IDE today! http://www.x-unity.net/teststudio.aspx "Gidi" <shnapsi@hotmail.com.dontspam> wrote in message news:E3F4411E-0690-4EFF-9579-911A92EBEE19@microsoft.com... > hello, > what i mean is that i want to take from each row and cell it's text and print it. > i need to do something like dataGrid[row,cell].ToString(); > > thanks > > "Dmitriy Lapshin [C# / .NET MVP]" wrote: > > > Hi, > > > > Do you mean the DataGrid rows or the underlying data rows? Could you please > > elaborate on what you're trying to achieve? > > > > -- > > Sincerely, > > Dmitriy Lapshin [C# / .NET MVP] > > Bring the power of unit testing to the VS .NET IDE today! > > http://www.x-unity.net/teststudio.aspx > > > > "Gidi" <shnapsi@hotmail.com.dontspam> wrote in message > > news:D7DCAB98-639E-4010-81C4-C623BD97257D@microsoft.com... > > > hello, i want to "run" on my DataGrid (in C#) on each row > > > i tried to do a foreach loop but i got erros, what is the correct syntax?? > > > > > > thanks... > > > >
- Next message: morphius: "Function Implementation"
- Previous message: Tamir Khason: "Re: Create DSN"
- In reply to: Gidi: "Re: Foreach with DataGrid"
- Next in thread: Scott Allen: "Re: Foreach with DataGrid"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|