2016-09-26 16 views
0

私はUltraGridを使用しており、AfterRowActivateイベントとCellChangeイベントの処理に関心があります。ブール型列と非アクティブ行のセルをクリックすると、最初のAfterRowActivateとCellChangeの両方のイベントがトリガーされます。 boolean型の列のセルをクリックしてイベントを発生させたAfterRowActivateを処理するメソッドで知る方法はありますか?したがって、CellChangeイベントも発生しますか?AfterRowActivateイベントとCellChangeイベントの同時処理

+0

CellChangedイベントの前に発生し、クリックされたセルに関する情報を含むAfterCellActivateがあります。 AfterRowActivateは、現在のセルに関する情報を持たない通常のEventArgsパラメーターを受け取ります。なぜあなたはAfterRowActivateを処理する必要がありますか? – Steve

+0

ポイントは、UltraDockManager内にUltraPanelがあり、アクティブな行がブー​​ル型の列をチェックしているかどうかによって、パネルを表示または非表示にしたいということです。だから私はAfterRowActivateパネルを表示または非表示にする必要があるだけでなく、同じ目的のためにCellChangeが必要です。 AfterCellActivateはCellChangeの前、AfterRowActivateの後に生成されるため、AfterRowActivateを処理するメソッドでは、ブール値のセルの値がその唯一のアクションの結果として変化するかどうかはわかりません(非ブール値のブール値列のセルをクリックすると、アクティブな行)。すべてのアイデアは非常に便利です。 @スティーブ – Robin

答えて

0

AfterRowActivateイベントでブールセルがクリックされたかどうかを直接見つける方法はありません。このイベントは、行セレクタをクリックした後に行がアクティブになったときに発生することがあります。あなたが試すことができるのは、ユーザーがクリックしたUIElementを取得することです。 UIElementがCheckEditorCheckBoxUIElementの場合、これはおそらくチェックボックスのセルがクリックされたことを示します。

private void UltraGrid1_AfterRowActivate(object sender, EventArgs e) 
{ 
    var grid = sender as UltraGrid; 
    if(grid == null) 
     return; 

    // Get the element where user clicked 
    var element = grid.DisplayLayout.UIElement.ElementFromPoint(grid.PointToClient(Cursor.Position)); 

    // Check if the element is CheckIndicatorUIElement. If so the user clicked exactly 
    // on the check box. The element's parent should be CheckEditorCheckBoxUIElement 
    CheckEditorCheckBoxUIElement checkEditorCheckBoxElement = null; 
    if(element is CheckIndicatorUIElement) 
    { 
     checkEditorCheckBoxElement = element.Parent as CheckEditorCheckBoxUIElement; 
    } 
    // Check if the element is CheckEditorCheckBoxUIElement. If so the user clicked 
    // on a check box cell, but not on the check box 
    else if(element is CheckEditorCheckBoxUIElement) 
    { 
     checkEditorCheckBoxElement = element as CheckEditorCheckBoxUIElement; 
    } 

    // If checkEditorCheckBoxElement is not null check box cell was clicked 
    if(checkEditorCheckBoxElement != null) 
    { 
     // You can get the cell from the parent of the parent of CheckEditorCheckBoxUIElement 
     // Here is the hierarchy: 
     // CellUIElement 
     //  EmbeddableCheckUIElement 
     //   CheckEditorCheckBoxUIElement 
     //    CheckIndicatorUIElement 
     // Find the CellUIElement and get the Cell of it 

     if(checkEditorCheckBoxElement.Parent != null && checkEditorCheckBoxElement.Parent.Parent != null) 
     { 
      var cellElement = checkEditorCheckBoxElement.Parent.Parent as CellUIElement; 
      if(cellElement != null) 
      { 
       var cell = cellElement.Cell; 
      } 
     } 
    } 
}