DataTable에서 채워진 XCeed Datagrid가 있습니다. 사용자가 셀을 두 번 클릭하면 어떤 행의 어떤 열이 선택되었는지를 결정할 수 있기를 원합니다. 어떻게해야합니까?XCeed Datagrid에서 두 번 클릭 한 행의 열을 어떻게 확인할 수 있습니까?
0
A
답변
1
음, 간결하게 질문하는 것은 요즘 처벌되는 것 같습니다. 어떤 코드도 제공하지 않습니다.
솔루션은 WPF 작성자에게 참으로 (엄청나게) 복잡합니다.
The solution for a standard WPF DataGrid can be found here.
난 당신이 DataCell 대상을 더블 클릭을 처리하는 (VB 단위) XCeed DataGridControl이 솔루션Public Class MyXAMLWindow
Private Sub grdResults_MouseDoubleClick(sender As Object, e As MouseButtonEventArgs)
'Cast the sender parameter to the XCeed DataGridControl'
Dim dg As Xceed.Wpf.DataGrid.DataGridControl = sender
'Extract the cell information to a custom CellInfo structure.'
Dim info = GetCellInfo(e.OriginalSource, dg.SelectedIndex)
'Pass the cellinfo to the ViewModel'
dg.DataContext.SelectedInfo = info
End Sub
''' <summary>
''' Contructs a <see cref="CellInfo(Of String)">cellinfo</see> structure from the cell that was clicked.
''' </summary>
''' <param name="originalSource">The value of the OriginalSource property of the MouseButtonEventArgs.</param>
''' <param name="rowIndex">The index of the row on which was clicked.</param>
''' <returns><see cref="CellInfo(Of string)">cellinfo</see> object.</returns>
''' <remarks>This function uses the OriginalSource property of the MouseButtonEventArgs as a starting point.</remarks>'
Private Function GetCellInfo(originalSource As Object, rowIndex As Integer) As CellInfo(Of String)
Dim dep As DependencyObject = originalSource
Dim cellInfo = New CellInfo(Of String)
'Find the DataCell that is associated with the original source.'
While (dep IsNot Nothing) AndAlso Not (TypeOf dep Is DataCell)
dep = VisualTreeHelper.GetParent(dep)
End While
If dep Is Nothing Then
Return New CellInfo(Of String) With {.ColumnIndex = -1, .RowIndex = -1, .Value = String.Empty}
End If
If TypeOf dep Is DataCell Then
Dim cell As DataCell = TryCast(dep, DataCell)
cellInfo.ColumnIndex = cell.ParentColumn.Index
cellInfo.RowIndex = rowIndex
cellInfo.Value = cell.Content
End If
Return cellInfo
End Function
End Class
'A custom Structure to hold the data of the selected Cell.'
Public Structure CellInfo(Of TValue)
Public RowIndex As Integer
Public ColumnIndex As Integer
Public Value As TValue
End Structure
0
먼저 재.
private void OnDataCellMouseDoubleClick(object sender, MouseButtonEventArgs e)
{
var clickedCell = sender as DataCell;
var row = clickedCell.ParentRow;
var rowNum = row.TabIndex;
var column = clickedCell.ParentColumn;
var columnNum = column.Index;
}
읽어 보시기 바랍니다 [ "어떻게 물어"] (http://stackoverflow.com/help/how- : 당신이 쓸 수있는 파일 뒤에 코드에서이 작업을 수행하려면
다음 처리기 메서드 간다 to-ask)를 사용하여 StackOverflow에 질문을 게시하십시오. –