Click here to Skip to main content
Rate this: bad
good
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;
 
TIA
Posted 6-Jun-11 22:32pm

1 solution

Rate this: bad
good
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[^]
 
EDIT
-------------------------
Using Calculated DataColumns in ADO.NET[^]
 
Calculate the running total in a datagridview[^](In Form load)
 
Loan Calculator Example using DataGridView[^]
  Permalink  
v2
Comments
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)



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