Click here to Skip to main content
11,584,040 members (62,780 online)
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 18:46pm
Edited 27-Mar-13 1:17am
ProgramFOX159.7K
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)

  Print Answers RSS
0 OriginalGriff 480
1 Sergey Alexandrovich Kryukov 285
2 virusstorm 268
3 Dave Kreskowiak 230
4 Richard Deeming 220
0 OriginalGriff 1,523
1 Sergey Alexandrovich Kryukov 995
2 Abhinav S 696
3 Dave Kreskowiak 621
4 Suvendu Shekhar Giri 568


Advertise | Privacy | Mobile
Web03 | 2.8.150603.1 | Last Updated 28 Mar 2013
Copyright © CodeProject, 1999-2015
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