如何删除DataGrid中的行(How to delete a row in datagrid)

2019-10-23 05:02发布

如何在DataGrid中删除行。 我使用下面的代码,它不工作我如何更改我的代码(前两行正在与3'rd线无法正常工作)。

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

Answer 1:

你尝试使用索引,而不是该行的?

put the dgHilitedIndex of me into theIndex 
DeleteIndex theIndex

该行始终是当前的显示顺序,说

A = 1

B = 2

C = 3

因此,如果你删除线2条,接下来的C线将成为第2行这通常是有点问题的。

删除行后:

A = 1

C = 2

在另一方面索引时填写的数据网格,并保持相同的一行,无论你如何对它进行排序分配。 这样,你总是可以找出该行

随着指数:

A = 1

B = 2

C = 3

后删除第2行:

A = 1

C = 3



Answer 2:

删除线DataGrid中有需要的情况下,调度命令你这样做的DataGrid之外。 例如,使用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


Answer 3:

我总是作为一个实践问题,做了明确的这样的事情。 LC中的工具和分析适当的比DG本身更为方便和强大。

所以一般:

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

克雷格·纽曼



Answer 4:

相同的答案MrCoolLion以更简洁的方式:

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


文章来源: How to delete a row in datagrid
标签: livecode