|
-
Jan 7th, 2005, 06:47 AM
#1
Thread Starter
Frenzied Member
DataGrid KeyPress Event
Hi all,
I need to work with keypress or keydown event of data grid. I have an editable datagrid, and when user enters data in the datagrid, I want to display total accordingly. For this purpose, I wrote code in Keypress event but event is not firing. Moreover, I tried KeyDown but its also not firing.
Any ideas ??
Thanks
-
Jan 24th, 2005, 07:16 PM
#2
Re: DataGrid KeyPress Event
You could use the CurrentCellChanged event, i.e.
Code:
private void dataGrid1_CurrentCellChanged(object sender, System.EventArgs e)
{
int index = dataGrid1.CurrentCell.ColumnNumber;
decimal total = 0;
foreach(DataRow row in ((DataTable)dataGrid1.DataSource).Rows)
if( row[index] != DBNull.Value )
total += Convert.ToDecimal(row[index]);
label1.Text = string.Format("Total for this column in {0}", total);
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|