'宣言 Public ReadOnly Property Column As UltraListViewColumnBase
public UltraListViewColumnBase Column {get;}
Imports Infragistics.Win Imports Infragistics.Win.UltraWinListView Private Function ColumnFromPoint(ByVal listView As UltraListView, ByVal point As Point) As UltraListViewColumnBase If listView Is Nothing Or listView.UIElement Is Nothing Then Return Nothing ' If there is an UltraListViewSubItem at the specified point, ' return a reference to its Column property Dim subItem As UltraListViewSubItem = listView.SubItemFromPoint(point) If Not subItem Is Nothing Then Return subItem.Column ' Try to find an UltraListViewColumnHeaderUIElement if we do, ' return a reference to its Column property Dim elementAtPoint As UIElement = listView.UIElement.ElementFromPoint(point) Dim headerElement As UltraListViewColumnHeaderUIElement = Nothing While (Not elementAtPoint Is Nothing) If elementAtPoint.GetType() Is GetType(UltraListViewColumnHeaderUIElement) Then headerElement = CType(elementAtPoint, UltraListViewColumnHeaderUIElement) Return headerElement.Column End If elementAtPoint = elementAtPoint.Parent End While Return Nothing End Function
using Infragistics.Win; using Infragistics.Win.UltraWinListView; using System.Diagnostics; private UltraListViewColumnBase ColumnFromPoint( UltraListView listView, Point point ) { if ( listView == null || listView.UIElement == null ) return null; // If there is an UltraListViewSubItem at the specified point, // return a reference to its Column property UltraListViewSubItem subItem = listView.SubItemFromPoint( point ); if ( subItem != null ) return subItem.Column; // Try to find an UltraListViewColumnHeaderUIElement; if we do, // return a reference to its Column property UIElement elementAtPoint = listView.UIElement.ElementFromPoint( point ); UltraListViewColumnHeaderUIElement headerElement = null; while ( elementAtPoint != null ) { headerElement = elementAtPoint as UltraListViewColumnHeaderUIElement; if ( headerElement != null ) return headerElement.Column; elementAtPoint = elementAtPoint.Parent; } return null; }