Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C# DataGridView
I have a DataGridView that is bound but it also has several unbound columns. I'm calculating the values in some of these unbound cells through values on the form including other cells that are bound.
I can successfully set the value of a cell, however, under no circumstances is the value being reflected on the UI. I've checked the value on the proper cells as I exit the method and they are correct. I've tried refreshing and updating, but still nothing appears on the front end.
Can anyone tell me why the UI is not showing the values?
This is using Winforms and not WPF if it matters.

I'm doing this in the usual way,
dgv.Rows[i].Cells[j].Value = val;
Posted 6-Jun-11 23:32pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Dude, I'm not sure that you are using any datagridview events. These links will help you.
Calculation in DataGridView cells[^]
Calculation in DataGridView column[^]
Implementing an Excel-like formula engine[^]
Using Calculated DataColumns in ADO.NET[^]
Calculate the running total in a datagridview[^](In Form load)
Loan Calculator Example using DataGridView[^]
Mustafa Ismail Mustafa at 7-Jun-11 7:48am
Well, there are initial calculations that I need to perform and these ought to happen at Form_Load(). I'll try to do that at the DatabindingComplete() event and come back with an answer
thatraja at 7-Jun-11 8:00am
For initial calculations, you can do calculations in Datatable/dataview & then you can bind that to Datagridview.
Check my updated answer.
Mustafa Ismail Mustafa at 7-Jun-11 7:53am
It worked! The question is why?! Why should it matter that I used an event to set the value whilst I cannot do it explicitly?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 398
1 DamithSL 255
2 OriginalGriff 230
3 Zoltán Zörgő 149
4 Dave Kreskowiak 120
0 OriginalGriff 7,575
1 DamithSL 5,529
2 Sergey Alexandrovich Kryukov 5,279
3 Maciej Los 4,961
4 Kornfeld Eliyahu Peter 4,539

Advertise | Privacy | Mobile
Web04 | 2.8.141223.1 | Last Updated 7 Jun 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100