473,503 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1141
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
7790
by: Daniel Jung | last post by:
Hi This is not a "CSS I want you to do for me since my boss needs it yesterday"... I am wondering about a few things, and I am still working on this, but wanted to share it with you at this...
32
14761
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
1
1229
by: Woody Splawn | last post by:
I have a datagrid. Through the normal means I highlight a record in the datagrid and press the delete key. I say yes and the record is deleted. However, in this case I need to run some code after...
2
1912
by: Ryan Liu | last post by:
private void dt_RowDeleted(object sender, DataRowChangeEventArgs e) { int id= (int)e.Row; if(id >5) { e.Row.RejectChanges(); MessageBox.Show(this, "Can not delete!" + id); }
13
2453
by: a.zeevi | last post by:
free() multiple allocation error in C ==================================== Hi! I have written a program in C on PC with Windows 2000 in a Visual C environment. I have an error in freeing...
5
9907
by: Neil | last post by:
I am getting time-out errors when I try to perform a simple delete on a linked server. The command is: Delete From MyTable Where PKID=12345 I have tried executing this command directly from...
5
3099
by: rn5a | last post by:
The .NET 2.0 documentation states the following: When using a DataSet or DataTable in conjunction with a DataAdapter & a relational data source, use the Delete method of the DataRow to remove...
7
15611
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is...
2
19721
by: Francesco Pietra | last post by:
Please, how to adapt the following script (to delete blank lines) to delete lines containing a specific word, or words? f=open("output.pdb", "r") for line in f: line=line.rstrip() if line:...
0
7086
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7460
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.