Home All Groups Group Topic Archive Search About

How to cancel deleting a row in an event

Author
25 Feb 2007 8:22 AM
Hamed
Hello

I need an event to be able to cancel a delete request to a DataRow object in
some conditions. It seems DataRowDeleting should be able to do the job but
setting e.Action is impossible (it is read-only)

How can I do the above job?

Thanks in advance
Hamed

Author
25 Feb 2007 8:43 AM
Hamed
I need an event to cancel deletion of a DataGrid row that the DataTable is
bound to.


Show quote
"Hamed" <ha***@raymehr.com> wrote in message
news:eP9FYZLWHHA.4764@TK2MSFTNGP05.phx.gbl...
> Hello
>
> I need an event to be able to cancel a delete request to a DataRow object
> in some conditions. It seems DataRowDeleting should be able to do the job
> but setting e.Action is impossible (it is read-only)
>
> How can I do the above job?
>
> Thanks in advance
> Hamed
>
Author
25 Feb 2007 9:38 AM
Cor Ligthert [MVP]
Hamed,

Reading your question over. Probably is this on our website your answer.

http://www.vb-tips.com/dbpages.aspx?ID=740184e1-a6df-4e31-8417-a1741d691945

I hope this helps,

Cor

Show quote
"Hamed" <ha***@raymehr.com> schreef in bericht
news:eJchokLWHHA.4028@TK2MSFTNGP04.phx.gbl...
>I need an event to cancel deletion of a DataGrid row that the DataTable is
> bound to.
>
>
> "Hamed" <ha***@raymehr.com> wrote in message
> news:eP9FYZLWHHA.4764@TK2MSFTNGP05.phx.gbl...
>> Hello
>>
>> I need an event to be able to cancel a delete request to a DataRow object
>> in some conditions. It seems DataRowDeleting should be able to do the job
>> but setting e.Action is impossible (it is read-only)
>>
>> How can I do the above job?
>>
>> Thanks in advance
>> Hamed
>>
>
>
>
Author
26 Feb 2007 6:24 AM
Hamed
Thanks Cor but in the code you mentioned if a cell is selected but the whole
row is not selected, it will be deleted that is not a desired occurrence.

any other suggestion is appreciated

Hamed

Show quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:%230tuQBMWHHA.2256@TK2MSFTNGP02.phx.gbl...
> Hamed,
>
> Reading your question over. Probably is this on our website your answer.
>
> http://www.vb-tips.com/dbpages.aspx?ID=740184e1-a6df-4e31-8417-a1741d691945
>
> I hope this helps,
>
> Cor
>
> "Hamed" <ha***@raymehr.com> schreef in bericht
> news:eJchokLWHHA.4028@TK2MSFTNGP04.phx.gbl...
>>I need an event to cancel deletion of a DataGrid row that the DataTable is
>> bound to.
>>
>>
>> "Hamed" <ha***@raymehr.com> wrote in message
>> news:eP9FYZLWHHA.4764@TK2MSFTNGP05.phx.gbl...
>>> Hello
>>>
>>> I need an event to be able to cancel a delete request to a DataRow
>>> object
>>> in some conditions. It seems DataRowDeleting should be able to do the
>>> job
>>> but setting e.Action is impossible (it is read-only)
>>>
>>> How can I do the above job?
>>>
>>> Thanks in advance
>>> Hamed
>>>
>>
>>
>>
>
>
Author
25 Feb 2007 8:43 AM
Hamed
I need an event to cancel deletion of a DataGrid row that the DataTable is
bound to.


Show quote
"Hamed" <ha***@raymehr.com> wrote in message
news:eP9FYZLWHHA.4764@TK2MSFTNGP05.phx.gbl...
> Hello
>
> I need an event to be able to cancel a delete request to a DataRow object
> in some conditions. It seems DataRowDeleting should be able to do the job
> but setting e.Action is impossible (it is read-only)
>
> How can I do the above job?
>
> Thanks in advance
> Hamed
>
Author
25 Feb 2007 8:43 AM
Hamed
I need an event to cancel deletion of a DataGrid row that the DataTable is
bound to.


Show quote
"Hamed" <ha***@raymehr.com> wrote in message
news:eP9FYZLWHHA.4764@TK2MSFTNGP05.phx.gbl...
> Hello
>
> I need an event to be able to cancel a delete request to a DataRow object
> in some conditions. It seems DataRowDeleting should be able to do the job
> but setting e.Action is impossible (it is read-only)
>
> How can I do the above job?
>
> Thanks in advance
> Hamed
>
Author
25 Feb 2007 9:38 AM
Cor Ligthert [MVP]
Hamed,

Reading your question over. Probably is this on our website your answer.

http://www.vb-tips.com/dbpages.aspx?ID=740184e1-a6df-4e31-8417-a1741d691945

I hope this helps,

Cor

Show quote
"Hamed" <ha***@raymehr.com> schreef in bericht
news:eJchokLWHHA.4028@TK2MSFTNGP04.phx.gbl...
>I need an event to cancel deletion of a DataGrid row that the DataTable is
> bound to.
>
>
> "Hamed" <ha***@raymehr.com> wrote in message
> news:eP9FYZLWHHA.4764@TK2MSFTNGP05.phx.gbl...
>> Hello
>>
>> I need an event to be able to cancel a delete request to a DataRow object
>> in some conditions. It seems DataRowDeleting should be able to do the job
>> but setting e.Action is impossible (it is read-only)
>>
>> How can I do the above job?
>>
>> Thanks in advance
>> Hamed
>>
>
>
>
Author
25 Feb 2007 9:38 AM
Cor Ligthert [MVP]
Hamed,

Reading your question over. Probably is this on our website your answer.

http://www.vb-tips.com/dbpages.aspx?ID=740184e1-a6df-4e31-8417-a1741d691945

I hope this helps,

Cor

Show quote
"Hamed" <ha***@raymehr.com> schreef in bericht
news:eJchokLWHHA.4028@TK2MSFTNGP04.phx.gbl...
>I need an event to cancel deletion of a DataGrid row that the DataTable is
> bound to.
>
>
> "Hamed" <ha***@raymehr.com> wrote in message
> news:eP9FYZLWHHA.4764@TK2MSFTNGP05.phx.gbl...
>> Hello
>>
>> I need an event to be able to cancel a delete request to a DataRow object
>> in some conditions. It seems DataRowDeleting should be able to do the job
>> but setting e.Action is impossible (it is read-only)
>>
>> How can I do the above job?
>>
>> Thanks in advance
>> Hamed
>>
>
>
>
Author
26 Feb 2007 6:24 AM
Hamed
Thanks Cor but in the code you mentioned if a cell is selected but the whole
row is not selected, it will be deleted that is not a desired occurrence.

any other suggestion is appreciated

Hamed

Show quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:%230tuQBMWHHA.2256@TK2MSFTNGP02.phx.gbl...
> Hamed,
>
> Reading your question over. Probably is this on our website your answer.
>
> http://www.vb-tips.com/dbpages.aspx?ID=740184e1-a6df-4e31-8417-a1741d691945
>
> I hope this helps,
>
> Cor
>
> "Hamed" <ha***@raymehr.com> schreef in bericht
> news:eJchokLWHHA.4028@TK2MSFTNGP04.phx.gbl...
>>I need an event to cancel deletion of a DataGrid row that the DataTable is
>> bound to.
>>
>>
>> "Hamed" <ha***@raymehr.com> wrote in message
>> news:eP9FYZLWHHA.4764@TK2MSFTNGP05.phx.gbl...
>>> Hello
>>>
>>> I need an event to be able to cancel a delete request to a DataRow
>>> object
>>> in some conditions. It seems DataRowDeleting should be able to do the
>>> job
>>> but setting e.Action is impossible (it is read-only)
>>>
>>> How can I do the above job?
>>>
>>> Thanks in advance
>>> Hamed
>>>
>>
>>
>>
>
>
Author
26 Feb 2007 6:24 AM
Hamed
Thanks Cor but in the code you mentioned if a cell is selected but the whole
row is not selected, it will be deleted that is not a desired occurrence.

any other suggestion is appreciated

Hamed

Show quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:%230tuQBMWHHA.2256@TK2MSFTNGP02.phx.gbl...
> Hamed,
>
> Reading your question over. Probably is this on our website your answer.
>
> http://www.vb-tips.com/dbpages.aspx?ID=740184e1-a6df-4e31-8417-a1741d691945
>
> I hope this helps,
>
> Cor
>
> "Hamed" <ha***@raymehr.com> schreef in bericht
> news:eJchokLWHHA.4028@TK2MSFTNGP04.phx.gbl...
>>I need an event to cancel deletion of a DataGrid row that the DataTable is
>> bound to.
>>
>>
>> "Hamed" <ha***@raymehr.com> wrote in message
>> news:eP9FYZLWHHA.4764@TK2MSFTNGP05.phx.gbl...
>>> Hello
>>>
>>> I need an event to be able to cancel a delete request to a DataRow
>>> object
>>> in some conditions. It seems DataRowDeleting should be able to do the
>>> job
>>> but setting e.Action is impossible (it is read-only)
>>>
>>> How can I do the above job?
>>>
>>> Thanks in advance
>>> Hamed
>>>
>>
>>
>>
>
>
Author
25 Feb 2007 8:43 AM
Cor Ligthert [MVP]
Hamed,

Reject changes is fine, not only for deleting.
(Be aware that it does not work for removing)

http://msdn2.microsoft.com/en-us/library/system.data.datarow.rejectchanges.aspx

it is there as well at datatable and dataset level
http://msdn2.microsoft.com/en-gb/library/system.data.datatable.rejectchanges.aspx

Cor

Show quote
"Hamed" <ha***@raymehr.com> schreef in bericht
news:eP9FYZLWHHA.4764@TK2MSFTNGP05.phx.gbl...
> Hello
>
> I need an event to be able to cancel a delete request to a DataRow object
> in some conditions. It seems DataRowDeleting should be able to do the job
> but setting e.Action is impossible (it is read-only)
>
> How can I do the above job?
>
> Thanks in advance
> Hamed
>
Author
25 Feb 2007 9:24 AM
Miha Markic [MVP C#]
I think that the only way is to throw an exception.
An ugly way btw.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Show quote
"Hamed" <ha***@raymehr.com> wrote in message
news:eP9FYZLWHHA.4764@TK2MSFTNGP05.phx.gbl...
> Hello
>
> I need an event to be able to cancel a delete request to a DataRow object
> in some conditions. It seems DataRowDeleting should be able to do the job
> but setting e.Action is impossible (it is read-only)
>
> How can I do the above job?
>
> Thanks in advance
> Hamed
>
Author
26 Feb 2007 5:09 AM
Hamed
"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:OG48U7LWHHA.2256@TK2MSFTNGP02.phx.gbl...
>I think that the only way is to throw an exception.
> An ugly way btw.
>



I read some threads such as the following but isn't there really a more neat
method to do the job?

http://groups.google.com/group/microsoft.public.dotnet.framework.windowsforms.databinding/browse_thread/thread/400571e860cdd22a/7fdc4a9383662d26?lnk=st&q=cancel+delete+datagrid+.net&rnum=2#7fdc4a9383662d26
Author
26 Feb 2007 9:12 AM
Miha Markic [MVP C#]
Honestly, I give up on controlling/cancelling row deletion. Instead I don't
allow deletion before it happens..

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/
Show quote
"Hamed" <ha***@raymehr.com> wrote in message
news:uiBPJSWWHHA.4668@TK2MSFTNGP04.phx.gbl...
>
>
> "Miha Markic [MVP C#]" <miha at rthand com> wrote in message
> news:OG48U7LWHHA.2256@TK2MSFTNGP02.phx.gbl...
>>I think that the only way is to throw an exception.
>> An ugly way btw.
>>
>
>
>
> I read some threads such as the following but isn't there really a more
> neat method to do the job?
>
> http://groups.google.com/group/microsoft.public.dotnet.framework.windowsforms.databinding/browse_thread/thread/400571e860cdd22a/7fdc4a9383662d26?lnk=st&q=cancel+delete+datagrid+.net&rnum=2#7fdc4a9383662d26
>

AddThis Social Bookmark Button