我搜索过,但我找不到问题的答案。我有一个移动到VirtualMode的ListView,但是当我尝试拖动操作时,它失败了。它找不到正确的插入索引,因为这些项是虚拟的。在虚拟模式下,如何正确拖动ListView项?
基本上问题是NearestIndex无论鼠标在哪里都返回-1。这段代码在进入虚拟模式之前就已经有效了。
int theTargetIdx = InsertionMark->NearestIndex( thePoint );
if ( theTargetIdx > -1 )
{
System::Drawing::Rectangle theItemBounds = GetItemRect( theTargetIdx );
if ( thePoint.Y > theItemBounds.Top + (theItemBounds.Height / 2) )
{
InsertionMark->AppearsAfterItem = true;
}
else
{
InsertionMark->AppearsAfterItem = false;
}
}
else
{
aArgs->Effect = System::Windows::Forms::DragDropEffects::None;
}
InsertionMark->Index = theTargetIdx;