Link to home
Start Free TrialLog in
Avatar of meyerc74
meyerc74

asked on

looping through datagrid rows and updating columns

i have a system.windows.forms.datagrid in which i want to loop through the rows.  while looping i need to get the value of two columns and update a third column.  

the datagrid datasource is a dataTable set at startup.

not to sure how to do this, can anyone get me started or point me in the right direction, thanks
Avatar of msdixon
msdixon

do it after you call the .DataBind() method on your grid.

the Items property of the grid correlates to the rows, and the Cells property of the item correlates to the cells in the row.

datagrid.Item[0].Cells[3] is the first row, forth cell.
Avatar of meyerc74

ASKER

i'm building a windows application using system.windows.forms.datagrid
oh, sorry. i haven't used the data grid much. we used a 3rd party grid. i'll see if i can find some time to help you figure this out.
ok...i found if i set my DataTable as a class member(rather than a local function var) i can loop through the DataTable rows, update and then reset the DataSource of my datagrid.

while this does do what i need it to do, it seems horribly inefficent, and i would prefer to do each row individually so the end user can see at any giving time which row is currently being processed.
ASKER CERTIFIED SOLUTION
Avatar of msdixon
msdixon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
excellent...thank you. the visibleRowCount worked.  probably should have seen that myself, but we live and learn :)

thanks again

no problem.

it wasn't very intuitive, and it brings up a question: if i have hidden columns or rows, would that throw things off? or are the hidden ones inaccessible?

glad i could help.