470,815 Members | 1,364 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,815 developers. It's quick & easy.

delete multiple lines in DataGrid, message always shown deleting the first line



private void dt_RowDeleted(object sender, DataRowChangeEventArgs e)
{
int id= (int)e.Row["id", DataRowVersion.Original];

if(id >5)
{
e.Row.RejectChanges();
MessageBox.Show(this, "Can not delete!" + id);
}

}
When multile lines are selected and deleted from the datagrid by using
delete key.

The warning message showned by MessageBox.Show() always same. id never
changed, always the firt one.

Is this a known bug, any work around?

Thanks a lot!
Ryan Liu
Mar 6 '06 #1
2 1062
Don't know if it applies in this case & don't have the details handy, but
whenever I've had to delete multiple rows, you have to start at the last one
and work your way up. Something about the id changing if you delete working
down

"Ryan Liu" wrote:


private void dt_RowDeleted(object sender, DataRowChangeEventArgs e)
{
int id= (int)e.Row["id", DataRowVersion.Original];

if(id >5)
{
e.Row.RejectChanges();
MessageBox.Show(this, "Can not delete!" + id);
}

}
When multile lines are selected and deleted from the datagrid by using
delete key.

The warning message showned by MessageBox.Show() always same. id never
changed, always the firt one.

Is this a known bug, any work around?

Thanks a lot!
Ryan Liu

Mar 7 '06 #2
I think this is very good point.

But it is out of my contorl. Deleteing multiple line by "Del" key and
raising deleted event are both build-in function of datagrid.

Maybe Microsoft should take your suggestion into account.

Ryan Liu
"Taras" <Ta***@discussions.microsoft.com> дʼ
news:18**********************************@microsof t.com...
Don't know if it applies in this case & don't have the details handy, but
whenever I've had to delete multiple rows, you have to start at the last one and work your way up. Something about the id changing if you delete working down

"Ryan Liu" wrote:


private void dt_RowDeleted(object sender, DataRowChangeEventArgs e)
{
int id= (int)e.Row["id", DataRowVersion.Original];

if(id >5)
{
e.Row.RejectChanges();
MessageBox.Show(this, "Can not delete!" + id);
}

}
When multile lines are selected and deleted from the datagrid by using
delete key.

The warning message showned by MessageBox.Show() always same. id never
changed, always the firt one.

Is this a known bug, any work around?

Thanks a lot!
Ryan Liu

Mar 7 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Daniel Jung | last post: by
32 posts views Thread by tshad | last post: by
1 post views Thread by Woody Splawn | last post: by
13 posts views Thread by a.zeevi | last post: by
5 posts views Thread by rn5a | last post: by
7 posts views Thread by =?Utf-8?B?TG9zdEluTUQ=?= | last post: by
2 posts views Thread by Francesco Pietra | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.