By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,320 Members | 2,109 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,320 IT Pros & Developers. It's quick & easy.

How to supress deleting a Row

P: n/a
Hello

I have a DataGrid that a is bound to a DataTable. Some of the rows in the
DataTable should not be deleted. How can I prohibit deleting of some
identified rows?

The problem could be specified in the following format too:

There is a DataView object that I want to prohibit deleting of some of its
DataRowView objects. that is: when drv.Delete() is called (drv is the
identified DataRowView) it doesn't delete the DataRowView object (suppress
that the Deleted tag is assigned to the RowState) . How can I do this job?
Regards
Hamed
Aug 14 '06 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Datagridview
AllowUserToDeleteRows {true or false}

Datagrid
set the allow delete of the dataview that is bound to it to false

dim dt as datatable
dim dv as dataview
dim dbg as datagrid

'Get the default view from the table
dv = dt.defaultview

'Disallow deleted
dv.allowdelete = false

'Set the datasource
dbg.datasource = dv

"Hamed" <ha***@raymehr.comwrote in message
news:eB**************@TK2MSFTNGP05.phx.gbl...
Hello

I have a DataGrid that a is bound to a DataTable. Some of the rows in the
DataTable should not be deleted. How can I prohibit deleting of some
identified rows?

The problem could be specified in the following format too:

There is a DataView object that I want to prohibit deleting of some of its
DataRowView objects. that is: when drv.Delete() is called (drv is the
identified DataRowView) it doesn't delete the DataRowView object (suppress
that the Deleted tag is assigned to the RowState) . How can I do this job?
Regards
Hamed

Aug 14 '06 #2

P: n/a
This technique disallows delete of whole grid. I want to prohibit delete of
some identified rows. for example I know that I should disallow deletion of
second row but others may be deleted.

Any help or comment is appreciated.

Hamed

"AMDRIT" <am****@hotmail.comwrote in message
news:er****************@TK2MSFTNGP04.phx.gbl...
Datagridview
AllowUserToDeleteRows {true or false}

Datagrid
set the allow delete of the dataview that is bound to it to false

dim dt as datatable
dim dv as dataview
dim dbg as datagrid

'Get the default view from the table
dv = dt.defaultview

'Disallow deleted
dv.allowdelete = false

'Set the datasource
dbg.datasource = dv

"Hamed" <ha***@raymehr.comwrote in message
news:eB**************@TK2MSFTNGP05.phx.gbl...
>Hello

I have a DataGrid that a is bound to a DataTable. Some of the rows in the
DataTable should not be deleted. How can I prohibit deleting of some
identified rows?

The problem could be specified in the following format too:

There is a DataView object that I want to prohibit deleting of some of
its DataRowView objects. that is: when drv.Delete() is called (drv is the
identified DataRowView) it doesn't delete the DataRowView object
(suppress that the Deleted tag is assigned to the RowState) . How can I
do this job?
Regards
Hamed


Aug 14 '06 #3

P: n/a
Hamed,

I'm in now way an expert, but could you use the Hittest to find the row the
user is trying to delete, and check within that row for the occurance of the
piece of data that specifies when you don't want to allow deletion? You could
then simply disallow this deletion.

I suppose this solution is determined by how complicated your rules are for
allowing / not allowing rows to be deleted.

Perhaps a bit more information on what determines whether your rows can /
can't be deleted may help someone find you solution?

James.

"Hamed" wrote:
This technique disallows delete of whole grid. I want to prohibit delete of
some identified rows. for example I know that I should disallow deletion of
second row but others may be deleted.

Any help or comment is appreciated.

Hamed

"AMDRIT" <am****@hotmail.comwrote in message
news:er****************@TK2MSFTNGP04.phx.gbl...
Datagridview
AllowUserToDeleteRows {true or false}

Datagrid
set the allow delete of the dataview that is bound to it to false

dim dt as datatable
dim dv as dataview
dim dbg as datagrid

'Get the default view from the table
dv = dt.defaultview

'Disallow deleted
dv.allowdelete = false

'Set the datasource
dbg.datasource = dv

"Hamed" <ha***@raymehr.comwrote in message
news:eB**************@TK2MSFTNGP05.phx.gbl...
Hello

I have a DataGrid that a is bound to a DataTable. Some of the rows in the
DataTable should not be deleted. How can I prohibit deleting of some
identified rows?

The problem could be specified in the following format too:

There is a DataView object that I want to prohibit deleting of some of
its DataRowView objects. that is: when drv.Delete() is called (drv is the
identified DataRowView) it doesn't delete the DataRowView object
(suppress that the Deleted tag is assigned to the RowState) . How can I
do this job?
Regards
Hamed


Aug 14 '06 #4

P: n/a
Hamid,

The check which row it is do you have to do of course yourself, but that
should be for every developer a piece of cake.

http://www.vb-tips.com/dbpages.aspx?...9-57ec163eaa17

I hope this helps,

Cor

"Hamed" <ha***@raymehr.comschreef in bericht
news:eB**************@TK2MSFTNGP05.phx.gbl...
Hello

I have a DataGrid that a is bound to a DataTable. Some of the rows in the
DataTable should not be deleted. How can I prohibit deleting of some
identified rows?

The problem could be specified in the following format too:

There is a DataView object that I want to prohibit deleting of some of its
DataRowView objects. that is: when drv.Delete() is called (drv is the
identified DataRowView) it doesn't delete the DataRowView object (suppress
that the Deleted tag is assigned to the RowState) . How can I do this job?
Regards
Hamed

Aug 14 '06 #5

P: n/a
James

The case is not strange. It is simply a Grid of rows in a database
application. the rule is if any row is referred (or used) in another table,
it cannot be deleted using the Del key in the Grid. If I can somehow
prohibit delete of a specified row, I simply do the job for the rows in the
bound DataTable.

Regards
Hamed
P.S. As far as I know, Hittest checks physical position of a point in the
Grid rectangle, If I am wrong please correct me. If I am right, then this is
not my case. I want to disallow deletion of a certain row in a DataView or a
DataTable that is bound to a Grid and may have a lot of records so the Grid
scrolls. How does Hittest help in such a case?
"James Vickers" <Ja**********@discussions.microsoft.comwrote in message
news:5D**********************************@microsof t.com...
Hamed,

I'm in now way an expert, but could you use the Hittest to find the row
the
user is trying to delete, and check within that row for the occurance of
the
piece of data that specifies when you don't want to allow deletion? You
could
then simply disallow this deletion.

I suppose this solution is determined by how complicated your rules are
for
allowing / not allowing rows to be deleted.

Perhaps a bit more information on what determines whether your rows can /
can't be deleted may help someone find you solution?

James.

"Hamed" wrote:
>This technique disallows delete of whole grid. I want to prohibit delete
of
some identified rows. for example I know that I should disallow deletion
of
second row but others may be deleted.

Any help or comment is appreciated.

Hamed

"AMDRIT" <am****@hotmail.comwrote in message
news:er****************@TK2MSFTNGP04.phx.gbl...
Datagridview
AllowUserToDeleteRows {true or false}

Datagrid
set the allow delete of the dataview that is bound to it to false

dim dt as datatable
dim dv as dataview
dim dbg as datagrid

'Get the default view from the table
dv = dt.defaultview

'Disallow deleted
dv.allowdelete = false

'Set the datasource
dbg.datasource = dv

"Hamed" <ha***@raymehr.comwrote in message
news:eB**************@TK2MSFTNGP05.phx.gbl...
Hello

I have a DataGrid that a is bound to a DataTable. Some of the rows in
the
DataTable should not be deleted. How can I prohibit deleting of some
identified rows?

The problem could be specified in the following format too:

There is a DataView object that I want to prohibit deleting of some of
its DataRowView objects. that is: when drv.Delete() is called (drv is
the
identified DataRowView) it doesn't delete the DataRowView object
(suppress that the Deleted tag is assigned to the RowState) . How can
I
do this job?
Regards
Hamed



Aug 14 '06 #6

P: n/a
Thanks Cor. I checked it. It seems it can solve my problem.

Regards
Hamed
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:e3******************@TK2MSFTNGP04.phx.gbl...
Hamid,

The check which row it is do you have to do of course yourself, but that
should be for every developer a piece of cake.

http://www.vb-tips.com/dbpages.aspx?...9-57ec163eaa17

I hope this helps,

Cor

"Hamed" <ha***@raymehr.comschreef in bericht
news:eB**************@TK2MSFTNGP05.phx.gbl...
>Hello

I have a DataGrid that a is bound to a DataTable. Some of the rows in the
DataTable should not be deleted. How can I prohibit deleting of some
identified rows?

The problem could be specified in the following format too:

There is a DataView object that I want to prohibit deleting of some of
its DataRowView objects. that is: when drv.Delete() is called (drv is the
identified DataRowView) it doesn't delete the DataRowView object
(suppress that the Deleted tag is assigned to the RowState) . How can I
do this job?
Regards
Hamed


Aug 15 '06 #7

P: n/a
Thanks Cor. I checked it. It seems it can solve my problem.

Regards
Hamed
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:e3******************@TK2MSFTNGP04.phx.gbl...
Hamid,

The check which row it is do you have to do of course yourself, but that
should be for every developer a piece of cake.

http://www.vb-tips.com/dbpages.aspx?...9-57ec163eaa17

I hope this helps,

Cor

"Hamed" <ha***@raymehr.comschreef in bericht
news:eB**************@TK2MSFTNGP05.phx.gbl...
>Hello

I have a DataGrid that a is bound to a DataTable. Some of the rows in the
DataTable should not be deleted. How can I prohibit deleting of some
identified rows?

The problem could be specified in the following format too:

There is a DataView object that I want to prohibit deleting of some of
its DataRowView objects. that is: when drv.Delete() is called (drv is the
identified DataRowView) it doesn't delete the DataRowView object
(suppress that the Deleted tag is assigned to the RowState) . How can I
do this job?
Regards
Hamed


Aug 15 '06 #8

P: n/a
Thanks Cor. I am going to check it.

It seems it can solve my problem.

Regards
Hamed
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:e3******************@TK2MSFTNGP04.phx.gbl...
Hamid,

The check which row it is do you have to do of course yourself, but that
should be for every developer a piece of cake.

http://www.vb-tips.com/dbpages.aspx?...9-57ec163eaa17

I hope this helps,

Cor

"Hamed" <ha***@raymehr.comschreef in bericht
news:eB**************@TK2MSFTNGP05.phx.gbl...
>Hello

I have a DataGrid that a is bound to a DataTable. Some of the rows in the
DataTable should not be deleted. How can I prohibit deleting of some
identified rows?

The problem could be specified in the following format too:

There is a DataView object that I want to prohibit deleting of some of
its DataRowView objects. that is: when drv.Delete() is called (drv is the
identified DataRowView) it doesn't delete the DataRowView object
(suppress that the Deleted tag is assigned to the RowState) . How can I
do this job?
Regards
Hamed



Aug 15 '06 #9

P: n/a
Hamed,

Yes it checks a psyhical position, but at the same time that "could" have
been used. I assumed that you were indicating a user would have to select a
row to delete, therefore, if they had to select it, you would know which it
was! The Hittest would have then allowed you to indicate the row (and
therefore every cell referenced by that row) that was due to be deleted.

As I said, not knowing your rules, if it were (say for example) any row that
did not contain the number 3, in cell 4 (rough example!) you could have
checked in cell 4, for the value, and if were not 3, allow deletion,
otherwise, not allow it!

Maybe in the .NET days a complicated way of doing things, but i'm from the
days of VB6, and work arounds were part of the fun back then.

As I said in my original post, i'm not an expert, but just someone trying to
help.

James.

"Hamed" wrote:
James

The case is not strange. It is simply a Grid of rows in a database
application. the rule is if any row is referred (or used) in another table,
it cannot be deleted using the Del key in the Grid. If I can somehow
prohibit delete of a specified row, I simply do the job for the rows in the
bound DataTable.

Regards
Hamed
P.S. As far as I know, Hittest checks physical position of a point in the
Grid rectangle, If I am wrong please correct me. If I am right, then this is
not my case. I want to disallow deletion of a certain row in a DataView or a
DataTable that is bound to a Grid and may have a lot of records so the Grid
scrolls. How does Hittest help in such a case?
"James Vickers" <Ja**********@discussions.microsoft.comwrote in message
news:5D**********************************@microsof t.com...
Hamed,

I'm in now way an expert, but could you use the Hittest to find the row
the
user is trying to delete, and check within that row for the occurance of
the
piece of data that specifies when you don't want to allow deletion? You
could
then simply disallow this deletion.

I suppose this solution is determined by how complicated your rules are
for
allowing / not allowing rows to be deleted.

Perhaps a bit more information on what determines whether your rows can /
can't be deleted may help someone find you solution?

James.

"Hamed" wrote:
This technique disallows delete of whole grid. I want to prohibit delete
of
some identified rows. for example I know that I should disallow deletion
of
second row but others may be deleted.

Any help or comment is appreciated.

Hamed

"AMDRIT" <am****@hotmail.comwrote in message
news:er****************@TK2MSFTNGP04.phx.gbl...
Datagridview
AllowUserToDeleteRows {true or false}

Datagrid
set the allow delete of the dataview that is bound to it to false

dim dt as datatable
dim dv as dataview
dim dbg as datagrid

'Get the default view from the table
dv = dt.defaultview

'Disallow deleted
dv.allowdelete = false

'Set the datasource
dbg.datasource = dv

"Hamed" <ha***@raymehr.comwrote in message
news:eB**************@TK2MSFTNGP05.phx.gbl...
Hello

I have a DataGrid that a is bound to a DataTable. Some of the rows in
the
DataTable should not be deleted. How can I prohibit deleting of some
identified rows?

The problem could be specified in the following format too:

There is a DataView object that I want to prohibit deleting of some of
its DataRowView objects. that is: when drv.Delete() is called (drv is
the
identified DataRowView) it doesn't delete the DataRowView object
(suppress that the Deleted tag is assigned to the RowState) . How can
I
do this job?
Regards
Hamed





Aug 15 '06 #10

This discussion thread is closed

Replies have been disabled for this discussion.