|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to supress deleting a RowHello
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 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 Show quote "Hamed" <ha***@raymehr.com> wrote in message news:eBZA5U4vGHA.4460@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 > 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 Show quote "AMDRIT" <amd***@hotmail.com> wrote in message news:erHmy%236vGHA.3964@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.com> wrote in message > news:eBZA5U4vGHA.4460@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 >> > > 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. Show quote "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" <amd***@hotmail.com> wrote in message > news:erHmy%236vGHA.3964@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.com> wrote in message > > news:eBZA5U4vGHA.4460@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 > >> > > > > > > > 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? Show quote "James Vickers" <JamesVick***@discussions.microsoft.com> wrote in message news:5D749070-EA09-4DBF-9BFC-F5BBCA02336B@microsoft.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" <amd***@hotmail.com> wrote in message >> news:erHmy%236vGHA.3964@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.com> wrote in message >> > news:eBZA5U4vGHA.4460@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 >> >> >> > >> > >> >> >> 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. Show quote "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" <JamesVick***@discussions.microsoft.com> wrote in message > news:5D749070-EA09-4DBF-9BFC-F5BBCA02336B@microsoft.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" <amd***@hotmail.com> wrote in message > >> news:erHmy%236vGHA.3964@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.com> wrote in message > >> > news:eBZA5U4vGHA.4460@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 > >> >> > >> > > >> > > >> > >> > >> > > > 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?ID=82ee4145-632c-42a1-83b9-57ec163eaa17 I hope this helps, Cor Show quote "Hamed" <ha***@raymehr.com> schreef in bericht news:eBZA5U4vGHA.4460@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 > Thanks Cor. I checked it. It seems it can solve my problem.
Regards Hamed Show quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:e3o5%23%237vGHA.4880@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?ID=82ee4145-632c-42a1-83b9-57ec163eaa17 > > I hope this helps, > > Cor > > "Hamed" <ha***@raymehr.com> schreef in bericht > news:eBZA5U4vGHA.4460@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 >> > > Thanks Cor. I checked it. It seems it can solve my problem.
Regards Hamed Show quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:e3o5%23%237vGHA.4880@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?ID=82ee4145-632c-42a1-83b9-57ec163eaa17 > > I hope this helps, > > Cor > > "Hamed" <ha***@raymehr.com> schreef in bericht > news:eBZA5U4vGHA.4460@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 >> > > Thanks Cor. I am going to check it.
It seems it can solve my problem. Regards Hamed Show quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:e3o5%23%237vGHA.4880@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?ID=82ee4145-632c-42a1-83b9-57ec163eaa17 > > I hope this helps, > > Cor > > "Hamed" <ha***@raymehr.com> schreef in bericht > news:eBZA5U4vGHA.4460@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 >> > > |
|||||||||||||||||||||||