Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
private void calcBill()
       {
           string am = "";
           string pm = "";
           float award;

           if (Convert.ToBoolean(dataGridView2.SelectedRows[0].Cells["AM"].Value) == true)
           {
               am = dataGridView2.SelectedRows[0].Cells["AM"].Value.ToString();
               award = 0.5f;
           }
           else
           {
               am = dataGridView2.SelectedRows[0].Cells["AM"].Value.ToString();
               award = 0.0f;
           }

         }

the variable award not changed properly, when click checkbox on gridview

[Edit]Code block added[/Edit]
Posted
Updated 27-Mar-13 1:17am
v3
Comments
Sergey Alexandrovich Kryukov 27-Mar-13 1:03am    
Why should anything fire? In your code sample, I don't see where you add an event handler to an invocation list of any event instance.
Nothing to fire, it looks like. :-)
—SA
Arun_nature 28-Mar-13 5:04am    
just u try that code ,
i want attendance on the gridview AM, PM
if i click AM Absent,the next cell shows award 0.5
this is my need,
but the event fired before shows award!!
Sergey Alexandrovich Kryukov 28-Mar-13 10:03am    
You need to get an edit control of the cell, make sure it's a check box, and then add an handler to the invocation list of the event CheckedChanged.
—SA

 
Share this answer
 
Please see my past answer, with code sample: Datagridview Event in C#[^].

—SA
 
Share this answer
 
call calcBill() method in gridview cell content click event
 
Share this answer
 
Comments
Arun_nature 28-Mar-13 2:15am    
i used gridview cell content click

the problem is award variable not get proper data

if i click am cell to false
it will fired but it shows true

what can i do help me please
josh-jw 28-Mar-13 3:46am    
Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() =>
{
calcBill();
}), DispatcherPriority.Background);

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900