How to delete a row in datagrid

╄→гoц情女王★ 提交于 2019-12-24 15:30:10

问题


How to delete a row in datagrid. I am using the following code and it's not working(first two lines are working and the 3'rd line is not working) how i change my code.

put the dgHilitedLines of group "DGP"  into theLine
   answer theLine
   DeleteLine theLine

回答1:


Did you try using the index instead of the line?

put the dgHilitedIndex of me into theIndex 
DeleteIndex theIndex

The line is always the current display order, say

A = 1

B = 2

C = 3

Thus if you delete line 2, the next line C will become line 2. This is usually a bit of a problem.

After delete line:

A = 1

C = 2

The index on the other hand is assigned when you fill the datagrid and stays the same for one row, no matter how you sort it. This way you can always identify that row

With index:

A = 1

B = 2

C = 3

After delete row 2:

A = 1

C = 3




回答2:


Delete line in DataGrid with Dispatch command is needed in case you do this outside the datagrid. E.g. with a button outside the datagrid.

on mouseUp
   put the dgHilitedLines of group "DGP"  into theLine
   answer "The selected line var is : " & theLine
   dispatch "deleteline" to group "DGP" with theLine  
   put the result into tDeleteresult
   if tDeleteresult is not empty 
   then 
      answer "There has been a problem deleting the line with message: "&tDeleteresult
   else
      answer "Line Deleted"
   end if
end mouseUp



回答3:


I always, as a matter of practice, do this sort of thing in the clear. The tools and analytics within LC proper are far more accessible and powerful than within the DG itself.

So in general:

  get the dgData of group "yourDG"
  delete line whatever of it
  set the dgData of group "yourDG" to it

Craig Newman




回答4:


Same answer as MrCoolLion in a more concise way:

put the dgHilitedLines of group "DataGrid" into theLineNo
dispatch "deleteline" to group "DataGrid" with  theLineNo


来源:https://stackoverflow.com/questions/30436489/how-to-delete-a-row-in-datagrid

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!