Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# WinForm
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 26-Mar-13 19:46pm
Edited 27-Mar-13 2:17am
ProgramFOX127.6K
v3
Comments
Sergey Alexandrovich Kryukov at 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 at 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 at 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
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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

Solution 3

Please see my past answer, with code sample: Datagridview Event in C#[^].
 
—SA
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

call calcBill() method in gridview cell content click event
  Permalink  
Comments
Arun_nature at 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 at 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)



Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 28 Mar 2013
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