如何在实现拖放操作时使 JTable 的 TransferHandler 高亮显示行?

huangapple go评论133阅读模式
英文:

How to make jtable transferhandler highlight a row when implementing DnD?

问题

怎样在拖放时突出显示光标下的行?

我需要识别我正在拖放的jtable中的行,而不是默认的传输处理程序提供的插入位置。

在识别了行本身之后,我期望importData(TransferSupport support) 可以处理细节。

英文:

How to highlight the row under the cursor when dragging and dropping?

I need to identify the row in the jtable I'm dragging onto, not the insert position which the default transfer handler supplies out of the box.

Having identified the row itself, I expect that importData(TransferSupport support) can handle the fine details.

答案1

得分: 0

这是 RadGridView 主题中已知的问题。目前,GridViewRow 的 ControlTemplate 没有针对 BorderBrush 和 BorderThickness 的模板绑定。这意味着你所进行的更改未传播到 GridViewRow 模板中的 Border 元素。我们将在正式发布时修复此问题。

然而,在当前情况下,你可以以另一种方式实现此功能。你只需在模板中找到该边框。以下是一个示例,演示如何实现此功能:

var border = rowItem.ChildrenOfType<Border>().FirstOrDefault();

if (border != null) {
    border.BorderBrush = new SolidColorBrush(Colors.Red);
    border.BorderThickness = new Thickness(1);
}
英文:

This is a known issue in the themes for RadGridView. Currently, the ControlTemplate for GridViewRow did not have Template bindings for BorderBrush and BorderThickness. This means that the change you are making did not get propagated to the Border element that is in the GridViewRow's template. We will fix this for our official release.

However, there is a way you can do this in the current situation. You should just find the border in the template. Here is an example of how to achieve this:

var border = rowItem.ChildrenOfType&lt;Border&gt;().FirstOrDefault();

if(border != null) {

    border.BorderBrush = new SolidColorBrush(Colors.Red);
    border.BorderThickness = new Thickness(1);

}

答案2

得分: 0

myTable.setDropMode(DropMode....); 是我想要的。

选项有:

DropMode.USE_SELECTION
DropMode.ON
DropMode.INSERT
DropMode.ON_OR_INSERT

最后一个选项(DropMode.ON_OR_INSERT)为我提供了比我所需更多的功能(这是好的) - 区分在其他行之间插入行和将数据放在行上的能力。我在提问之前应该更多地进行研究。

英文:

myTable.setDropMode(DropMode....); is what I was after.

Options are:

 DropMode.USE_SELECTION
    DropMode.ON
    DropMode.INSERT
    DropMode.ON_OR_INSERT

The final one ( DropMode.ON_OR_INSERT) provided me with more than what I needed, (which is good) - the ability to distinguish between inserting a row between other rows, AND an indication of dropping data ONTO a row.
I should have done more research initially before posing the question.

huangapple
  • 本文由 发表于 2020年1月30日 19:42:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/59985286.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定